@@ -35,15 +35,11 @@ protocol Pattern {
35
35
36
36
func matched< C: Collection > ( atStartOf c: C ) -> MatchResult < Index , MatchData >
37
37
where C. Index == Index , C. Element == Element
38
- // The following requirements go away with upcoming generics features
39
- , C. SubSequence : Collection
40
38
}
41
39
42
40
extension Pattern {
43
41
func found< C: Collection > ( in c: C ) -> ( extent: Range < Index > , data: MatchData ) ?
44
42
where C. Index == Index , C. Element == Element
45
- // The following requirements go away with upcoming generics features
46
- , C. SubSequence : Collection
47
43
{
48
44
var i = c. startIndex
49
45
while i != c. endIndex {
@@ -72,8 +68,6 @@ where T.Element : Equatable {
72
68
73
69
func matched< C: Collection > ( atStartOf c: C ) -> MatchResult < Index , ( ) >
74
70
where C. Index == Index , C. Element == Element
75
- // The following requirements go away with upcoming generics features
76
- , C. SubSequence : Collection
77
71
{
78
72
var i = c. startIndex
79
73
for p in pattern {
@@ -93,8 +87,6 @@ struct MatchAnyOne<T : Equatable, Index : Comparable> : Pattern {
93
87
94
88
func matched< C: Collection > ( atStartOf c: C ) -> MatchResult < Index , ( ) >
95
89
where C. Index == Index , C. Element == Element
96
- // The following requirements go away with upcoming generics features
97
- , C. SubSequence : Collection
98
90
{
99
91
return c. isEmpty
100
92
? . notFound( resumeAt: c. endIndex)
@@ -126,8 +118,6 @@ where M0.Element == M1.Element, M0.Index == M1.Index {
126
118
127
119
func matched< C: Collection > ( atStartOf c: C ) -> MatchResult < Index , MatchData >
128
120
where C. Index == Index , C. Element == Element
129
- // The following requirements go away with upcoming generics features
130
- , C. SubSequence : Collection
131
121
{
132
122
var src0 = c [ c. startIndex..< c. endIndex]
133
123
while true {
@@ -166,8 +156,6 @@ struct RepeatMatch<M0: Pattern> : Pattern {
166
156
167
157
func matched< C: Collection > ( atStartOf c: C ) -> MatchResult < M0 . Index , MatchData >
168
158
where C. Index == M0 . Index , C. Element == M0 . Element
169
- // The following requirements go away with upcoming generics features
170
- , C. SubSequence : Collection
171
159
{
172
160
var lastEnd = c. startIndex
173
161
var rest = c. dropFirst ( 0 )
@@ -176,11 +164,11 @@ struct RepeatMatch<M0: Pattern> : Pattern {
176
164
searchLoop:
177
165
while !rest. isEmpty {
178
166
switch singlePattern. matched ( atStartOf: rest) {
179
- case . found( let x ) :
180
- data. append ( x )
181
- lastEnd = x . end
167
+ case . found( let end1 , let data1 ) :
168
+ data. append ( ( end1 , data1 ) )
169
+ lastEnd = end1
182
170
if data. count == repeatLimits. upperBound { break }
183
- rest = rest [ x . end ..< rest. endIndex]
171
+ rest = rest [ end1 ..< rest. endIndex]
184
172
case . notFound( let r) :
185
173
if !repeatLimits. contains ( data. count) {
186
174
return . notFound( resumeAt: r)
@@ -236,8 +224,6 @@ where M0.Element == M1.Element, M0.Index == M1.Index {
236
224
237
225
func matched< C: Collection > ( atStartOf c: C ) -> MatchResult < Index , MatchData >
238
226
where C. Index == Index , C. Element == Element
239
- // The following requirements go away with upcoming generics features
240
- , C. SubSequence : Collection
241
227
{
242
228
switch matchers. 0 . matched ( atStartOf: c) {
243
229
case . found( let end, let data) :
@@ -292,8 +278,6 @@ struct MatchStaticString : Pattern {
292
278
293
279
func matched< C: Collection > ( atStartOf c: C ) -> MatchResult < Index , ( ) >
294
280
where C. Index == Index , C. Element == Element
295
- // The following requirements go away with upcoming generics features
296
- , C. SubSequence : Collection
297
281
{
298
282
return content. withUTF8Buffer {
299
283
LiteralMatch < Buffer , Index > ( $0) . matched ( atStartOf: c)
@@ -327,8 +311,7 @@ extension Pattern where Element == UTF8.CodeUnit {
327
311
in c: C ,
328
312
format: ( MatchData ) -> String = { String ( reflecting: $0) } )
329
313
where C. Index == Index , C. Element == Element
330
- // The following requirements go away with upcoming generics features
331
- , C. SubSequence : Collection {
314
+ {
332
315
print ( " searching for / \( self ) / in \( c. u8str) ... " , terminator: " " )
333
316
if let ( extent, data) = self . found ( in: c) {
334
317
print (
@@ -382,8 +365,6 @@ struct Paired<T: Hashable, I: Comparable> : Pattern {
382
365
383
366
func matched< C: Collection > ( atStartOf c: C ) -> MatchResult < Index , MatchData >
384
367
where C. Index == Index , C. Element == Element
385
- // The following requirements go away with upcoming generics features
386
- , C. SubSequence : Collection
387
368
{
388
369
guard let closer = c. first. flatMap ( { pairs [ $0] } ) else {
389
370
return . notFound( resumeAt: nil )
0 commit comments