File tree Expand file tree Collapse file tree 1 file changed +29
-3
lines changed Expand file tree Collapse file tree 1 file changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -156,9 +156,35 @@ public struct ReversedCollection<
156
156
157
157
public typealias IndexDistance = Base . IndexDistance
158
158
159
- /// A type that provides the sequence's iteration interface and
160
- /// encapsulates its iteration state.
161
- public typealias Iterator = IndexingIterator < ReversedCollection >
159
+ @_fixed_layout
160
+ public struct Iterator : IteratorProtocol , Sequence {
161
+ @_inlineable
162
+ @inline ( __always)
163
+ public /// @testable
164
+ init ( elements: Base , endPosition: Base . Index ) {
165
+ self . _elements = elements
166
+ self . _position = endPosition
167
+ }
168
+
169
+ @_inlineable
170
+ @inline ( __always)
171
+ public mutating func next( ) -> Base . Iterator . Element ? {
172
+ guard _fastPath ( _position != _elements. startIndex) else { return nil }
173
+ _position = _elements. index ( before: _position)
174
+ return _elements [ _position]
175
+ }
176
+
177
+ @_versioned
178
+ internal let _elements : Base
179
+ @_versioned
180
+ internal var _position : Base . Index
181
+ }
182
+
183
+ @_inlineable
184
+ @inline ( __always)
185
+ public func makeIterator( ) -> Iterator {
186
+ return Iterator ( elements: _base, endPosition: _base. endIndex)
187
+ }
162
188
163
189
@_inlineable
164
190
public var startIndex : Index {
You can’t perform that action at this time.
0 commit comments