We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 604bef8 commit d175e89Copy full SHA for d175e89
Sources/_StringProcessing/Engine/Processor.swift
@@ -108,12 +108,13 @@ extension Processor {
108
// Returns whether the advance succeeded. On failure, our
109
// save point was restored
110
mutating func consume(_ n: Distance) -> Bool {
111
- // Want Collection to provide this behavior...
112
- if input.distance(from: currentPosition, to: end) < n.rawValue {
+ guard let idx = input.index(
+ currentPosition, offsetBy: n.rawValue, limitedBy: end
113
+ ) else {
114
signalFailure()
115
return false
116
}
- currentPosition = input.index(currentPosition, offsetBy: n.rawValue)
117
+ currentPosition = idx
118
return true
119
120
0 commit comments