mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[stdlib] Add post-nil guarantee for IteratorProtocol.next() to always return nil
This commit is contained in:
@@ -84,10 +84,8 @@ public struct EnumeratedIterator<
|
||||
/// The type of element returned by `next()`.
|
||||
public typealias Element = (offset: Int, element: Base.Element)
|
||||
|
||||
/// Advance to the next element and return it, or `nil` if no next
|
||||
/// element exists.
|
||||
///
|
||||
/// - Requires: No preceding call to `self.next()` has returned `nil`.
|
||||
/// Advance to the next element and return it, or `nil` if no next element
|
||||
/// exists. Once `nil` has been returned, all subsequent calls return `nil`.
|
||||
public mutating func next() -> Element? {
|
||||
guard let b = _base.next() else { return nil }
|
||||
defer { _count += 1 }
|
||||
|
||||
Reference in New Issue
Block a user