Skip to content

Commit

Permalink
Merge pull request apple#31911 from valeriyvan/FixRangeReplaceableCol…
Browse files Browse the repository at this point in the history
…lectionFilter

[SR-12648] Fixes filter function of RangeReplaceableCollection.
  • Loading branch information
CodaFi committed May 28, 2020
2 parents 5ec1e3e + a0b6517 commit b78bd2e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion stdlib/public/core/RangeReplaceableCollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,11 @@ extension RangeReplaceableCollection {
public __consuming func filter(
_ isIncluded: (Element) throws -> Bool
) rethrows -> Self {
return try Self(self.lazy.filter(isIncluded))
var result = Self()
for element in self where try isIncluded(element) {
result.append(element)
}
return result
}
}

Expand Down

0 comments on commit b78bd2e

Please sign in to comment.