File tree Expand file tree Collapse file tree 1 file changed +5
-12
lines changed Expand file tree Collapse file tree 1 file changed +5
-12
lines changed Original file line number Diff line number Diff line change @@ -85,11 +85,6 @@ extension Stride: Collection where Base: Collection {
85
85
self . base = base
86
86
}
87
87
88
- init ? ( _ base: Base . Index ? ) {
89
- guard let base = base else { return nil }
90
- self . base = base
91
- }
92
-
93
88
public static func < ( lhs: Index , rhs: Index ) -> Bool {
94
89
lhs. base < rhs. base
95
90
}
@@ -122,7 +117,7 @@ extension Stride: Collection where Base: Collection {
122
117
123
118
return n > 0
124
119
? offsetForward ( i, offsetBy: n, limitedBy: limit)
125
- : offsetBackward ( i, offsetBy: n, limitedBy: limit)
120
+ : offsetBackward ( i, offsetBy: - n, limitedBy: limit)
126
121
}
127
122
128
123
private func offsetForward(
@@ -160,15 +155,13 @@ extension Stride: Collection where Base: Collection {
160
155
limitedBy limit: Index
161
156
) -> Index ? {
162
157
let distance = i == endIndex
163
- ? - ( ( base. count - 1 ) % stride + 1 ) + ( n + 1 ) * stride
164
- : n * stride
165
- return Index (
166
- base. index (
158
+ ? - ( ( base. count - 1 ) % stride + 1 ) + ( 1 - n) * stride
159
+ : n * - stride
160
+ return base. index (
167
161
i. base,
168
162
offsetBy: distance,
169
163
limitedBy: limit. base
170
- )
171
- )
164
+ ) . map ( Index . init)
172
165
}
173
166
174
167
public var count : Int {
You can’t perform that action at this time.
0 commit comments