drop_some 1.0.1

`.drop_some` syntax sugar for `Option`. It's instead of `.map(|_|())`.
Documentation
  • Coverage
  • 66.67%
    2 out of 3 items documented1 out of 2 items with examples
  • Size
  • Source code size: 5.95 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.02 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • usagi/drop_some
    1 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • usagi

drop_some

  • This crate defines DropSome trait and impl for Option.
  • DropSome trait has .drop_some(self) -> Option<()> function.
  • This is a syntax sugar for .map(|_|()).

Useful scene

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 */ }
  • See also: <tests/test.rs>

Note

"I don't need it, because ..."

  • Yes, your are right to your world.
    • But, I tired to type/see .map(|_|()). So I'm happy with.drop_some().

LICENSE

Author