~matthiasbeyer/resiter

Helpers for handling `Iterator<Item = Result<O, E>>` in Rust
Remove some old rust versions from CI, add some new ones
Merge remote-tracking branch 'github/master'
Merge branch 'to-srht'

clone

read-only
https://git.sr.ht/~matthiasbeyer/resiter
read/write
git@git.sr.ht:~matthiasbeyer/resiter

You can also use your local clone with git send-email.

#resiter

Build Status Issue Stats Issue Stats license Tokei

A collection of helpful iterator adaptors for iterating over Result<T, E>.

#Examples

Here go some examples what you can do with the library.

  • Altering T in Iterator<Item = Result<T, E>>
iter.map(|r| r.map(|a| alter(a))) // stdlib
iter.map_ok(|a| alter(a))         // resiter
  • Altering T in Iterator<Item = Result<T, E>> with a function that might fail:
iter.map(|r| r.and_then(|a| alter(a))) // stdlib
iter.and_then_ok(|a| alter(a))         // resiter
  • Unpacking T in Iterator<Item = Result<Option<T>, E>>
iter.map(|r| r.and_then(|o| o.ok_or_else(|| error()))) // stdlib
iter.inner_ok_or_else(|| error())                      // resiter
  • Executing code for each error in Iterator<Item = Result<T, E>>
iter.map(|r| if let Err(e) = r { foo(); Err(e) } else { r })) // stdlib
iter.map(|r| r.map_err(|e| { foo(); e }))                     // stdlib
iter.on_err(|e| foo())                                        // resiter

#License

MPL 2.0