Simple Macros, changing the flow of development:
kill!( flow )
panicsexit!( flow )
returns::default()
next!( flow )
continueshold!( flow )
breaks
Flow can be:
- Option
..!{ inner = option }
same aslet Some(inner) = option else {..}
..!{ ?option }
same asif option.is_none() {..}
- Result
..!{ inner = result }
same aslet Ok(inner) = result else {..}
..!{ ?result }
same asif result.is_err() {..}
- bool
..!{ if bool }
same asif bool {..}
- custom
..!{ *Some(inner) = option }
same aslet Some(inner) = option else {..}
[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 ..
}
}
..implements the trait YayNay
for Result
, Option
and bool
with those methods:
.yay()
returnstrue
ifOk(..)
Some(..)
ortrue
.nay()
returnstrue
for the negative counter part
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.