File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -159,7 +159,27 @@ extension Span /*: Sequence /* where Element: ~Copyable */ */ {
159159
160160extension InlineArray : Sequence /* where Element: ~Copyable */ {
161161 public typealias Element = Element
162- public typealias Iterator = NeverIterator < Element >
162+ // public typealias Iterator = NeverIterator<Element>
163+ public typealias BorrowingIterator = Span < Element >
164+
165+ // This will NOT work once `Element: ~Copyable` is in the works
166+ // Problematic because we can only conform to `Sequence` once, so we
167+ // need to provide a single iterator type, but it can't handle both
168+ // ~Copyable and copyable elements (I think)
169+ public struct Iterator : IteratorProtocol {
170+ var array : [ count of Element]
171+ var index : Int = 0
172+
173+ public mutating func next( ) -> Element ? {
174+ guard index < array. count else { return nil }
175+ defer { index &+= 1 }
176+ return array [ index]
177+ }
178+ }
179+
180+ public func makeIterator( ) -> Iterator {
181+ . init( array: self )
182+ }
163183
164184 @_alwaysEmitIntoClient
165185 @_lifetime ( borrow self)
You can’t perform that action at this time.
0 commit comments