5 releases (breaking)

Uses old Rust 2015

0.5.0 Apr 26, 2023
0.4.0 Oct 25, 2019
0.3.0 Dec 19, 2018
0.2.0 Oct 29, 2018
0.1.0 Feb 22, 2018

#237 in Rust patterns

Download history 3057/week @ 2024-07-27 2454/week @ 2024-08-03 2078/week @ 2024-08-10 1939/week @ 2024-08-17 1939/week @ 2024-08-24 2460/week @ 2024-08-31 1941/week @ 2024-09-07 1425/week @ 2024-09-14 1608/week @ 2024-09-21 1592/week @ 2024-09-28 1370/week @ 2024-10-05 1184/week @ 2024-10-12 1543/week @ 2024-10-19 1007/week @ 2024-10-26 1767/week @ 2024-11-02 1162/week @ 2024-11-09

5,682 downloads per month
Used in 69 crates (31 directly)

MPL-2.0 license

64KB
1K SLoC

resiter

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

No runtime deps