Skip to content

Commit 4419614

Browse files
Move post-nil guarantee to separate line for Iterators' next()
1 parent ab9e74c commit 4419614

14 files changed

+51
-21
lines changed

stdlib/public/core/Algorithm.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ public struct EnumeratedIterator<
8585
public typealias Element = (offset: Int, element: Base.Element)
8686

8787
/// Advances to the next element and returns it, or `nil` if no next element
88-
/// exists. Once `nil` has been returned, all subsequent calls return `nil`.
88+
/// exists.
89+
///
90+
/// Once `nil` has been returned, all subsequent calls return `nil`.
8991
public mutating func next() -> Element? {
9092
guard let b = _base.next() else { return nil }
9193
defer { _count += 1 }

stdlib/public/core/Collection.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,11 @@ public struct IndexingIterator<
296296
}
297297

298298
/// Advances to the next element and returns it, or `nil` if no next element
299-
/// exists. Once `nil` has been returned, all subsequent calls return `nil`.
299+
/// exists.
300300
///
301301
/// Repeatedly calling this method returns all the elements of the underlying
302-
/// sequence in order. As soon as the sequence has run out of elements, the
303-
/// `next()` method returns `nil`.
302+
/// sequence in order. As soon as the sequence has run out of elements, all
303+
/// subsequent calls return `nil`.
304304
///
305305
/// This example shows how an iterator can be used explicitly to emulate a
306306
/// `for`-`in` loop. First, retrieve a sequence's iterator, and then call

stdlib/public/core/CollectionOfOne.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ public struct IteratorOverOne<Element> : IteratorProtocol, Sequence {
2020
}
2121

2222
/// Advances to the next element and returns it, or `nil` if no next element
23-
/// exists. Once `nil` has been returned, all subsequent calls return `nil`.
23+
/// exists.
24+
///
25+
/// Once `nil` has been returned, all subsequent calls return `nil`.
2426
///
2527
/// - Precondition: `next()` has not been applied to a copy of `self`
2628
/// since the copy was made.

stdlib/public/core/ExistentialCollection.swift.gyb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ public struct AnyIterator<Element> : IteratorProtocol {
7575
}
7676

7777
/// Advances to the next element and returns it, or `nil` if no next element
78-
/// exists. Once `nil` has been returned, all subsequent calls return `nil`.
78+
/// exists.
79+
///
80+
/// Once `nil` has been returned, all subsequent calls return `nil`.
7981
public func next() -> Element? {
8082
return _box.next()
8183
}
@@ -97,7 +99,9 @@ internal struct _ClosureBasedIterator<Element> : IteratorProtocol {
9799

98100
internal class _AnyIteratorBoxBase<Element> : IteratorProtocol {
99101
/// Advances to the next element and returns it, or `nil` if no next element
100-
/// exists. Once `nil` has been returned, all subsequent calls return `nil`.
102+
/// exists.
103+
///
104+
/// Once `nil` has been returned, all subsequent calls return `nil`.
101105
///
102106
/// - Note: Subclasses must override this method.
103107
internal func next() -> Element? { _abstract() }

stdlib/public/core/Filter.swift.gyb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ public struct LazyFilterIterator<
2727
Base : IteratorProtocol
2828
> : IteratorProtocol, Sequence {
2929
/// Advances to the next element and returns it, or `nil` if no next element
30-
/// exists. Once `nil` has been returned, all subsequent calls return `nil`.
30+
/// exists.
31+
///
32+
/// Once `nil` has been returned, all subsequent calls return `nil`.
3133
///
3234
/// - Precondition: `next()` has not been applied to a copy of `self`
3335
/// since the copy was made.

stdlib/public/core/Flatten.swift.gyb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ public struct FlattenIterator<
3636
}
3737

3838
/// Advances to the next element and returns it, or `nil` if no next element
39-
/// exists. Once `nil` has been returned, all subsequent calls return `nil`.
39+
/// exists.
40+
///
41+
/// Once `nil` has been returned, all subsequent calls return `nil`.
4042
///
4143
/// - Precondition: `next()` has not been applied to a copy of `self`
4244
/// since the copy was made.

stdlib/public/core/HashedCollections.swift.gyb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4574,7 +4574,9 @@ public struct ${Self}Iterator<${TypeParametersDecl}> : IteratorProtocol {
45744574
}
45754575

45764576
/// Advances to the next element and returns it, or `nil` if no next element
4577-
/// exists. Once `nil` has been returned, all subsequent calls return `nil`.
4577+
/// exists.
4578+
///
4579+
/// Once `nil` has been returned, all subsequent calls return `nil`.
45784580
@inline(__always)
45794581
public mutating func next() -> ${Sequence}? {
45804582
if _fastPath(_guaranteedNative) {

stdlib/public/core/Join.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ public struct JoinedIterator<
3737
}
3838

3939
/// Advances to the next element and returns it, or `nil` if no next element
40-
/// exists. Once `nil` has been returned, all subsequent calls return `nil`.
40+
/// exists.
41+
///
42+
/// Once `nil` has been returned, all subsequent calls return `nil`.
4143
public mutating func next() -> Base.Element.Iterator.Element? {
4244
repeat {
4345
switch _state {

stdlib/public/core/Map.swift.gyb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ public struct LazyMapIterator<
2525
Base : IteratorProtocol, Element
2626
> : IteratorProtocol, Sequence {
2727
/// Advances to the next element and returns it, or `nil` if no next element
28-
/// exists. Once `nil` has been returned, all subsequent calls return `nil`.
28+
/// exists.
29+
///
30+
/// Once `nil` has been returned, all subsequent calls return `nil`.
2931
///
3032
/// - Precondition: `next()` has not been applied to a copy of `self`
3133
/// since the copy was made.

stdlib/public/core/Sequence.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ public protocol IteratorProtocol {
182182
/// exists. Once `nil` has been returned, all subsequent calls return `nil`.
183183
///
184184
/// Repeatedly calling this method returns, in order, all the elements of the
185-
/// underlying sequence. After the sequence has run out of elements, the
186-
/// `next()` method returns `nil`.
185+
/// underlying sequence. As soon as the sequence has run out of elements, all
186+
/// subsequent calls return `nil`.
187187
///
188188
/// You must not call this method if any other copy of this iterator has been
189189
/// advanced with a call to its `next()` method.
@@ -1179,7 +1179,9 @@ public struct IteratorSequence<
11791179
}
11801180

11811181
/// Advances to the next element and returns it, or `nil` if no next element
1182-
/// exists. Once `nil` has been returned, all subsequent calls return `nil`.
1182+
/// exists.
1183+
///
1184+
/// Once `nil` has been returned, all subsequent calls return `nil`.
11831185
///
11841186
/// - Precondition: `next()` has not been applied to a copy of `self`
11851187
/// since the copy was made.

0 commit comments

Comments
 (0)