5 releases
new 0.1.4 | Nov 11, 2024 |
---|---|
0.1.3 | Nov 8, 2024 |
0.1.2 | May 9, 2022 |
0.1.1 | May 8, 2022 |
0.1.0 | May 8, 2022 |
#518 in Rust patterns
241 downloads per month
9KB
185 lines
fn_macro
Example
use fn_macro::prelude::*;
#[test]
fn test() {
assert_eq!(1, if_else!(true, 1, 2));
assert_eq!(1, if_unwrap_or_default!(Some(1)));
assert_eq!(1, if_unwrap_or_default!(None, 1));
assert_eq!(1, if_ok_or_default!(Ok::<i32, String>(1)));
assert_eq!(1, if_ok_or_default!(Err(""), 1));
let mut v:Option<i32>= None;
assert_eq!(0, if_panic!(v.unwrap()));
assert_eq!(1, if_panic!(v.unwrap(), 1));
println!("{:?}", hashmap!(1 => 2));
println!("{:?}", hashmap!(1 => 2, 2 => 3));
println!("{:?}", btreeset!(1,2));
println!("{:?}", hashset!(1,2));
}