diff --git a/stdlib/public/core/Algorithm.swift b/stdlib/public/core/Algorithm.swift index a3fe61253d54a..2b8ca062737a5 100644 --- a/stdlib/public/core/Algorithm.swift +++ b/stdlib/public/core/Algorithm.swift @@ -168,7 +168,9 @@ public struct EnumerateGenerator< /// - Requires: No preceding call to `self.next()` has returned `nil`. public mutating func next() -> Element? { guard let b = base.next() else { return nil } - return (index: count++, element: b) + let element = (index: count, element: b) + count += 1 + return element } }