https://github.com/carlsverre/tryiter
Utility functions for Iterators of Results
https://github.com/carlsverre/tryiter
extension iterator library result rust
Last synced: 12 months ago
JSON representation
Utility functions for Iterators of Results
- Host: GitHub
- URL: https://github.com/carlsverre/tryiter
- Owner: carlsverre
- License: apache-2.0
- Created: 2024-11-06T22:27:04.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-30T17:17:03.000Z (over 1 year ago)
- Last Synced: 2025-07-04T04:11:48.786Z (12 months ago)
- Topics: extension, iterator, library, result, rust
- Language: Rust
- Homepage:
- Size: 29.3 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
tryiter
Utility functions for Iterators of Results. This crate is heavily inspired by [TryStreamExt] in the [futures] crate as well as Yoshua Wuyts post on [Fallible Iterator Adapters].
[futures]: https://docs.rs/futures
[TryStreamExt]: https://docs.rs/futures/latest/futures/stream/trait.TryStreamExt.html
[Fallible Iterator Adapters]:https://blog.yoshuawuyts.com/fallible-iterator-adapters/
## `TryIteratorExt`
This crate exports a trait called `TryIteratorExt` which provides utility methods on top of any Iterator which returns a `Result`. `TryIteratorExt` is automatically implemented on top of compatible Iterators via a generic `impl` so all you have to do is import the trait and start calling methods on your iterators.
The methods provide two fundamental simplifications over regular Iterator methods:
1. They operate directly on `Ok` or `Err` values, passing through the other values transparently.
2. They take in fallible closures which can return `Err`.
See [tests/sanity.rs](./tests/sanity.rs) for a quick overview of using this crate.
## Release Stability
This crate is still pre-1.0 and will be until someone wants to use it in production. If you want to use it before that point please pin a specific version number and be prepared for breaking changes.