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 {
8585 self . base = base
8686 }
8787
88- init ? ( _ base: Base . Index ? ) {
89- guard let base = base else { return nil }
90- self . base = base
91- }
92-
9388 public static func < ( lhs: Index , rhs: Index ) -> Bool {
9489 lhs. base < rhs. base
9590 }
@@ -122,7 +117,7 @@ extension Stride: Collection where Base: Collection {
122117
123118 return n > 0
124119 ? offsetForward ( i, offsetBy: n, limitedBy: limit)
125- : offsetBackward ( i, offsetBy: n, limitedBy: limit)
120+ : offsetBackward ( i, offsetBy: - n, limitedBy: limit)
126121 }
127122
128123 private func offsetForward(
@@ -160,15 +155,13 @@ extension Stride: Collection where Base: Collection {
160155 limitedBy limit: Index
161156 ) -> Index ? {
162157 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 (
167161 i. base,
168162 offsetBy: distance,
169163 limitedBy: limit. base
170- )
171- )
164+ ) . map ( Index . init)
172165 }
173166
174167 public var count : Int {
You can’t perform that action at this time.
0 commit comments