File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -265,6 +265,33 @@ extension LazyFilterCollection : LazyCollectionProtocol, Collection {
265
265
}
266
266
}
267
267
268
+ @_inlineable // FIXME(sil-serialize-all)
269
+ public func distance( from start: Index , to end: Index ) -> Int {
270
+ // The following line makes sure that distance(from:to:) is invoked on the
271
+ // _base at least once, to trigger a _precondition in forward only
272
+ // collections.
273
+ _ = _base. distance ( from: start, to: end)
274
+ var _start : Index
275
+ let _end : Index
276
+ let step : Int
277
+ if start > end {
278
+ _start = end
279
+ _end = start
280
+ step = - 1
281
+ }
282
+ else {
283
+ _start = start
284
+ _end = end
285
+ step = 1
286
+ }
287
+ var count = 0
288
+ while _start != _end {
289
+ count += step
290
+ formIndex ( after: & _start)
291
+ }
292
+ return count
293
+ }
294
+
268
295
@_inlineable // FIXME(sil-serialize-all)
269
296
public func index( _ i: Index , offsetBy n: Int ) -> Index {
270
297
var i = i
You can’t perform that action at this time.
0 commit comments