Crates.io | maflow |
lib.rs | maflow |
version | 0.1.0 |
source | src |
created_at | 2024-07-01 16:46:21.952578 |
updated_at | 2024-07-01 16:46:21.952578 |
description | Flow macros: basically unwrap for return, continue and break |
homepage | |
repository | https://github.com/dekirisu/maflow |
max_upload_size | |
id | 1288858 |
size | 19,607 |
Simple Macros, changing the flow of development:
kill!( flow )
panicsexit!( flow )
returns ::default()
next!( flow )
continueshold!( flow )
breaksFlow can be:
..!{ inner = option }
same as if Some(inner) = option {..}
..!{ inner = result }
same as if Ok(inner) = option {..}
..!{ if bool }
same as if bool {..}
[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()
returns true
if Ok(..)
Some(..)
or true
.nay()
returns true
for the negative counter part