Skip to content

Conversation

@airspeedswift
Copy link
Member

Adds more on top of #85294

Azoy and others added 8 commits November 3, 2025 13:43
This change allows noncopyable and nonescapable Sequence types, with
room for generalizing the Element type to be ~Copyable in the future.
The new prototype adds a BorrowingIterator associated type to Sequence

This commit adds a BorrowingIteratorProtocol for generalized bulk
iteration, a BorrowingIteratorAdapter as an implementation of the new
Sequence requirement for existing sequences, and a NeverIterator for
new noncopyable/nonescapable sequence types. Conformance to Sequence
for Span and InlineArray is also included.

Issues:
- Availability checking must be off due to the availability
  requirements on the new Sequence.BorrowingIterator associated type
- Several existing sequences needed an explicit Element type alias to
  compile (note that this was during experimentation, so it may be
  possible to back out these changes)
- Some of the default implementations for generalized sequences simply
  fatal error
- InlineArray is a tricky case, due to its conditionally copyable
  design. It conforms to Sequence unconditionally, so it needs an
  unconditional implementation of (the original) Iterator associated
  type. However, when Sequence can use ~Copyable elements, that
  implementation won't be workable, since (a) it copies the inline
  array, and (b) it implements the `next() -> Element?` method, which
  can't return a noncopyable element.
@airspeedswift
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants