Crates.io | drop_ok |
lib.rs | drop_ok |
version | 1.0.2 |
source | src |
created_at | 2020-08-10 07:16:36.098353 |
updated_at | 2020-08-10 08:04:37.231287 |
description | `.drop_ok` syntax sugar for `Result`. It's instead of `.map(|_|())`. |
homepage | |
repository | https://github.com/usagi/drop_ok |
max_upload_size | |
id | 274958 |
size | 6,560 |
DropOk<E>
trait and impl
for Result
.DropOk<E>
trait has .drop_ok(self) -> Result<(), E>
function..map(|_|())
.fn some_function() -> Result<(), MyError>
{
match switcher
{
pattern_a => some_task1().drop_ok()?
pattern_b => some_task2().drop_ok()?
pattern_c => some_task3()?
pattern_d => some_task4()
_ => ()
}
}
fn some_task1() -> Result<i8 , MyError> { /* abbr */ }
fn some_task2<'a>() -> Result<&'a str, MyError> { /* abbr */ }
fn some_task3() -> Result<() , MyError> { /* abbr */ }
fn some_task4() { /* abbr */ }
"I don't need it, because ..."
.map(|_|())
. So I'm happy with.drop_ok()
.