maflow 0.1.0

Flow macros: basically unwrap for return, continue and break
Documentation
  • Coverage
  • 0%
    0 out of 11 items documented0 out of 3 items with examples
  • Size
  • Source code size: 19.11 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.31 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 12s Average build duration of successful builds.
  • all releases: 12s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • dekirisu/maflow
    5 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • dekirisu

Simple Macros, changing the flow of development:

  • kill!( flow ) panics
  • exit!( flow ) returns ::default()
  • next!( flow ) continues
  • hold!( flow ) breaks

Flow can be:

  1. Option ..!{ inner = option } same as if Some(inner) = option {..}
  2. Result ..!{ inner = result } same as if Ok(inner) = option {..}
  3. bool ..!{ if bool } same as if bool {..}

Example

[dependencies]

maflow = "0.1"

use maflow::*;
fn main(){
    // Options and Results
    let some = Some(true);
    kill!{is_true = some} // same as .unwrap()
    exit!{is_true = some} // returns default() if None => ()
    for i in 0..9 {
        next!{is_true = some} // continues if None
        hold!{is_true = some} // breaks if None
        if is_true {}
    }
    // Conditional
    let is_true = true;
    kill!{if is_true} // panics if ..
    exit!{if is_true} // returns default() if ..
    for i in 0..9 {
        next!{if is_true} // continues if ..
        hold!{if is_true} // breaks if ..
    }
}

Also..

..implements the trait YayNay for Result, Option and bool with those methods:

  • .yay() returns true if Ok(..) Some(..) or true
  • .nay() returns true for the negative counter part

License