Skip to content

Instantly share code, notes, and snippets.

@robertmryan
Created November 29, 2024 19:28
Show Gist options
  • Save robertmryan/3127092969b144335ae9f5186d7d97fc to your computer and use it in GitHub Desktop.
Save robertmryan/3127092969b144335ae9f5186d7d97fc to your computer and use it in GitHub Desktop.
/// Find `Counter` with particular `number`
///
/// This uses `async` from [Swift async algorithms](https://github.com/apple/swift-async-algorithms/blob/main/Sources/AsyncAlgorithms/AsyncAlgorithms.docc/Guides/Lazy.md)
/// to make an `AsyncSequence` from the `counters` collection.
func getCounter3(number: Int) async -> Counter? {
await counters.async.first { counter in
await counter.number == number
}
}
@robertmryan
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment