Skip to content

Commit 439f535

Browse files
committed
Stop increasing the nextIndex beyond endIndex in BagIterator.
1 parent 30abe6f commit 439f535

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Sources/Bag.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ public struct BagIterator<Element>: IteratorProtocol {
9696

9797
public mutating func next() -> Element? {
9898
let currentIndex = nextIndex
99-
nextIndex = currentIndex + 1
10099

101100
if currentIndex < endIndex {
101+
nextIndex = currentIndex + 1
102102
return base[currentIndex].value
103103
}
104104

0 commit comments

Comments
 (0)