Skip to content

Commit eaea1c6

Browse files
committed
Merge pull request #575 from nielsandriesse/patch-16
Update BidirectionalIndexType for removal of ++ operator
2 parents 55f7d76 + f725352 commit eaea1c6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

stdlib/public/core/Index.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,10 @@ extension BidirectionalIndexType {
288288
return _advanceForward(n)
289289
}
290290
var p = self
291-
for var i: Distance = n; i != 0; ++i {
292-
--p
291+
var i: Distance = n
292+
while i != 0 {
293+
p._predecessorInPlace()
294+
i._successorInPlace()
293295
}
294296
return p
295297
}
@@ -300,8 +302,10 @@ extension BidirectionalIndexType {
300302
return _advanceForward(n, limit)
301303
}
302304
var p = self
303-
for var i: Distance = n; i != 0 && p != limit; ++i {
304-
--p
305+
var i: Distance = n
306+
while i != 0 && p != limit {
307+
p._predecessorInPlace()
308+
i._successorInPlace()
305309
}
306310
return p
307311
}

0 commit comments

Comments
 (0)