imply_option 0.1.2

Provides a single `trait` which allows the construction of an `Option` based on a bool value.
Documentation
  • Coverage
  • 100%
    4 out of 4 items documented1 out of 4 items with examples
  • Size
  • Source code size: 2.3 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 72.65 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 7s Average build duration of successful builds.
  • all releases: 7s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Dynisious/imply_option
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Dynisious

An implementation of this RFC.

Provides a single trait which allows the construction of an Option based on a bool value.

extern crate imply_option;

use imply_option::*;

fn main() {
    let pass = true;

    assert_eq!(pass.then(1), Some(1));
    assert_eq!(pass.then_do(|| 1), Some(1));

    let fail = false;

    assert_eq!(fail.then(1), None);
}