Crates.io | lift_result |
lib.rs | lift_result |
version | 1.0.1 |
source | src |
created_at | 2022-05-06 05:02:03.666156 |
updated_at | 2022-05-06 15:49:39.089987 |
description | Lifts a fallible function that returns Result<_, E1> into one that returns Result<_, E2>, if E1 can be automatically converted into E2. |
homepage | |
repository | https://github.com/NinoScript/lift-result/ |
max_upload_size | |
id | 581484 |
size | 4,344 |
Lifts a fallible function that fails with error E1, into one that fails with error E2.
I had my own Error
type, turning another result into mine was easy and nice
result.map_err(Error::from)
But when I wanted to apply a fallible function via .and_then
, I had to do this:
result.and_then(|x| failable(x).map_err(|e| e.into()))
And I didn't like that:
So I wrote this library. Yay, programming! 🎉
result
.map_err(Error::from)
.and_then(lift(failable))
Thank you cargo-readme for generating this README for me.
License: MIT OR Apache-2.0