@@ -115,7 +115,7 @@ extension EnumeratedSequence: Collection where Base: Collection {
115
115
@_alwaysEmitIntoClient
116
116
init ( base: Base . Index , offset: Int ) {
117
117
self . base = base
118
- self . offset = offset
118
+ self . _offset = offset
119
119
}
120
120
}
121
121
@@ -150,7 +150,7 @@ extension EnumeratedSequence: Collection where Base: Collection {
150
150
@available ( SwiftStdlib 6 . 1 , * )
151
151
@_alwaysEmitIntoClient
152
152
func _offset( of index: Index ) -> Int {
153
- index. base == _base. endIndex ? _base. count : index. offset
153
+ index. base == _base. endIndex ? _base. count : index. _offset
154
154
}
155
155
156
156
@available ( SwiftStdlib 6 . 1 , * )
@@ -159,21 +159,21 @@ extension EnumeratedSequence: Collection where Base: Collection {
159
159
if start. base == _base. endIndex || end. base == _base. endIndex {
160
160
return _base. distance ( from: start. base, to: end. base)
161
161
} else {
162
- return end. offset - start. offset
162
+ return end. _offset - start. _offset
163
163
}
164
164
}
165
165
166
166
@available ( SwiftStdlib 6 . 1 , * )
167
167
@_alwaysEmitIntoClient
168
168
public func index( after index: Index ) -> Index {
169
- Index ( base: _base. index ( after: index. base) , offset: index. offset + 1 )
169
+ Index ( base: _base. index ( after: index. base) , offset: index. _offset + 1 )
170
170
}
171
171
172
172
@available ( SwiftStdlib 6 . 1 , * )
173
173
@_alwaysEmitIntoClient
174
174
public func index( _ i: Index , offsetBy distance: Int ) -> Index {
175
175
let index = _base. index ( i. base, offsetBy: distance)
176
- let offset = distance >= 0 ? i. offset : _offset ( of: i)
176
+ let offset = distance >= 0 ? i. _offset : _offset ( of: i)
177
177
return Index ( base: index, offset: offset + distance)
178
178
}
179
179
@@ -187,32 +187,32 @@ extension EnumeratedSequence: Collection where Base: Collection {
187
187
guard let index = _base. index (
188
188
i. base,
189
189
offsetBy: distance,
190
- limitedBy: limit
190
+ limitedBy: limit. base
191
191
) else {
192
192
return nil
193
193
}
194
194
195
- let offset = distance >= 0 ? i. offset : _offset ( of: i)
195
+ let offset = distance >= 0 ? i. _offset : _offset ( of: i)
196
196
return Index ( base: index, offset: offset + distance)
197
197
}
198
198
199
199
@available ( SwiftStdlib 6 . 1 , * )
200
200
@_alwaysEmitIntoClient
201
- public subscript( _ position: Int ) -> Element {
201
+ public subscript( _ position: Index ) -> Element {
202
202
_precondition (
203
203
_base. startIndex <= position. base && position. base < _base. endIndex,
204
204
" Index out of bounds "
205
205
)
206
206
207
- return ( position. offset , _base [ position. base] )
207
+ return ( position. _offset , _base [ position. base] )
208
208
}
209
209
}
210
210
211
211
@available ( SwiftStdlib 6 . 1 , * )
212
212
extension EnumeratedSequence . Index : Comparable {
213
213
@available ( SwiftStdlib 6 . 1 , * )
214
214
@_alwaysEmitIntoClient
215
- public static == ( lhs: Self , rhs: Self ) -> Bool {
215
+ public static func == ( lhs: Self , rhs: Self ) -> Bool {
216
216
lhs. base == rhs. base
217
217
}
218
218
@@ -224,7 +224,7 @@ extension EnumeratedSequence.Index: Comparable {
224
224
}
225
225
226
226
@available ( SwiftStdlib 6 . 1 , * )
227
- extension EnumeratedSequence : BidirectionalCollection where Base: BidirectionalCollection {
227
+ extension EnumeratedSequence : BidirectionalCollection where Base: BidirectionalCollection & RandomAccessCollection {
228
228
@available ( SwiftStdlib 6 . 1 , * )
229
229
@_alwaysEmitIntoClient
230
230
public func index( before index: Index ) -> Index {
0 commit comments