Skip to content

Commit 077a8a1

Browse files
committed
[Sequence] Add default Iterator typealias for Sequences that are also Iterators
1 parent cf89ea7 commit 077a8a1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

stdlib/public/core/Sequence.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,13 @@ public protocol Sequence {
612612
) -> (Iterator,UnsafeMutableBufferPointer<Element>.Index)
613613
}
614614

615+
// Provides a default associated type witness for Iterator when the
616+
// Self type is both a Sequence and an Iterator.
617+
extension Sequence where Self: IteratorProtocol {
618+
// @_implements(Sequence, Iterator)
619+
public typealias _Default_Iterator = Self
620+
}
621+
615622
/// A default makeIterator() function for `IteratorProtocol` instances that
616623
/// are declared to conform to `Sequence`
617624
extension Sequence where Self.Iterator == Self {
@@ -622,7 +629,6 @@ extension Sequence where Self.Iterator == Self {
622629
}
623630
}
624631

625-
626632
/// A sequence that lazily consumes and drops `n` elements from an underlying
627633
/// `Base` iterator before possibly returning the first available element.
628634
///

0 commit comments

Comments
 (0)