Crates.io | drop_some |
lib.rs | drop_some |
version | 1.0.1 |
source | src |
created_at | 2020-08-10 07:56:47.425733 |
updated_at | 2020-08-10 08:03:25.026444 |
description | `.drop_some` syntax sugar for `Option`. It's instead of `.map(|_|())`. |
homepage | |
repository | https://github.com/usagi/drop_some |
max_upload_size | |
id | 274965 |
size | 6,328 |
DropSome
trait and impl
for Option
.DropSome
trait has .drop_some(self) -> Option<()>
function..map(|_|())
.fn some_function() -> Option<()>
{
match switcher
{
pattern_a => some_task1().drop_some()?
pattern_b => some_task2().drop_some()?
pattern_c => some_task3()?
pattern_d => some_task4()
_ => ()
}
}
fn some_task1() -> Option<i8 > { /* abbr */ }
fn some_task2<'a>() -> Option<&'a str> { /* abbr */ }
fn some_task3() -> Option<() > { /* abbr */ }
fn some_task4() { /* abbr */ }
"I don't need it, because ..."
.map(|_|())
. So I'm happy with.drop_some()
.