Created
November 29, 2024 19:28
-
-
Save robertmryan/3127092969b144335ae9f5186d7d97fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// 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 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Alternatively, see https://gist.github.com/robertmryan/aa279babad83d30ec6ed5a0d49f92023.