Sequence.swift 354 B

123456789101112
  1. #if swift(<6.0)
  2. extension Sequence {
  3. /// Back-ported implementation of `count(where:)` for pre Swift 6.
  4. func count(where predicate: (Element) -> Bool) -> Int {
  5. var count = 0
  6. for element in self where predicate(element) {
  7. count += 1
  8. }
  9. return count
  10. }
  11. }
  12. #endif