Skip to content

Commit 3f46ee3

Browse files
committed
Merge pull request #358 from chriseidhof/simplify-filter
Simplify filter implementation
2 parents 6250d78 + 6857b0c commit 3f46ee3

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

stdlib/public/core/Filter.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,12 @@ public struct LazyFilterGenerator<
2525
/// since the copy was made, and no preceding call to `self.next()`
2626
/// has returned `nil`.
2727
public mutating func next() -> Base.Element? {
28-
var n: Base.Element?
29-
for/*ever*/;; {
30-
n = _base.next()
31-
if n != nil ? _predicate(n!) : true {
28+
while let n = _base.next() {
29+
if _predicate(n) {
3230
return n
3331
}
3432
}
33+
return nil
3534
}
3635

3736
/// Creates an instance that produces the elements `x` of `base`

0 commit comments

Comments
 (0)