Last active
June 6, 2026 21:32
-
-
Save gistya/93dad6f39d2be55af3aa82212c76a335 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protocol BulkIterator { | |
| associatedtype Element | |
| associatedtype Failure: Error = Never | |
| mutating func nextSpan(maximumCount: Int) throws(Failure) -> Element | |
| } | |
| protocol Iterable where Iterator.Failure == Failure, Iterator.Element == Element { | |
| associatedtype Element | |
| associatedtype Failure: Error = Never | |
| associatedtype Iterator: BulkIterator | |
| func makeIterator() -> Iterator | |
| } | |
| public protocol Sequence<Element> { | |
| associatedtype Element | |
| associatedtype Iterator: IteratorProtocol where Iterator.Element == Element | |
| func makeIterator() -> Iterator | |
| } | |
| public protocol IteratorProtocol { | |
| associatedtype Element | |
| mutating func next() -> Element? | |
| } | |
| /// Wrapper | |
| protocol _Sequence { | |
| typealias __Element = Element | |
| typealias __Failure = Failure | |
| typealias __Iterator = BulkIterator | |
| } | |
| /// Wrapper | |
| protocol _Iterable { | |
| typealias _Element = Element | |
| typealias _Failure = Failure | |
| typealias _Iterator = BulkIterator | |
| } | |
| /// Array that conforms to both | |
| struct Array<_E, F: Error, _I: BulkIterator, I: IteratorProtocol>: _Sequence, _Iterable | |
| where I.Element == _E { | |
| typealias _Element = _E | |
| typealias _Iterator = _I | |
| typealias _Failure = F | |
| typealias __Element = _Element | |
| typealias __Iterator = I | |
| // Makes a Sequence.Iterator | |
| func makeIterator() -> I { fatalError() } | |
| // Makes an Iterable.BulkIterator | |
| func makeIterator() -> _I { fatalError () } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment