Crates.io | resiter |
lib.rs | resiter |
version | 0.5.0 |
source | src |
created_at | 2018-02-22 10:35:02.877495 |
updated_at | 2023-04-26 13:11:53.019485 |
description | Helper crate for handling iterators over result |
homepage | |
repository | https://git.beyermatthi.as/resiter |
max_upload_size | |
id | 52375 |
size | 93,763 |
A collection of helpful iterator adaptors for iterating over Result<T, E>
.
Here go some examples what you can do with the library.
Iterator<Item = Result<T, E>>
iter.map(|r| r.map(|a| alter(a))) // stdlib
iter.map_ok(|a| alter(a)) // resiter
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
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
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
MPL 2.0