Hello all! The associated type and related names are obviously a point of concern here, so I'd like to suggest a few alternatives to IterableIterator for further discussion:
SpanIterator
Switching to SpanIterator would change the protocols in this way:
protocol Iterable<Element, Failure>: ~Copyable, ~Escapable {
associatedtype Element: ~Copyable
associatedtype Failure: Error = Never
associatedtype SpanIterator: SpanIteratorProtocol<Element, Failure>
@_lifetime(borrow self)
func makeSpanIterator() -> SpanIterator
// ...
}
protocol SpanIteratorProtocol<Element, Failure>: ~Copyable, ~Escapable {
associatedtype Element: ~Copyable
associatedtype Failure: Error = Never
// ...
}
The current version of the proposal includes a type called SpanIterator that just wraps a single Span – that could be renamed to SingleSpanIterator or could be nested under Span. In that case, each of the types currently using SpanIterator as its iterator type would change to Span.SpanIterator.
Spans
The much briefer name Spans feels related to the associated type names in the Sequence and Collection sphere: Index, Indices, and SubSequence. For better or worse, this approach would make Iterable feel slightly less connected to the Sequence protocol and its iterator type:
protocol Iterable<Element, Failure>: ~Copyable, ~Escapable {
associatedtype Element: ~Copyable
associatedtype Failure: Error = Never
associatedtype Spans: SpansProvider<Element, Failure>
@_lifetime(borrow self)
func spans() -> Spans
// ...
}
protocol SpansProvider<Element, Failure>: ~Copyable, ~Escapable {
associatedtype Element: ~Copyable
associatedtype Failure: Error = Never
// ...
}
BorrowingIterator
Lastly, we could use the new Iterator name with the BorrowingIterator names from the original proposal.
protocol Iterable<Element, Failure>: ~Copyable, ~Escapable {
associatedtype Element: ~Copyable
associatedtype Failure: Error = Never
associatedtype BorrowingIterator: BorrowingIteratorProtocol<Element, Failure>
@_lifetime(borrow self)
func makeBorrowingIterator() -> BorrowingIterator
// ...
}
protocol BorrowingIteratorProtocol<Element, Failure>: ~Copyable, ~Escapable {
associatedtype Element: ~Copyable
associatedtype Failure: Error = Never
// ...
}