fn_macro

Crates.iofn_macro
lib.rsfn_macro
version0.1.4
created_at2022-05-08 14:54:33.500475+00
updated_at2024-11-11 02:42:50.77919+00
description函数宏
homepagehttps://github.com/ptechen
repositoryhttps://github.com/ptechen/fn_macro.git
max_upload_size
id582561
size20,498
Petechen (ptechen)

documentation

https://github.com/ptechen/fn_macro/blob/master/README.md

README

fn_macro

Version info Downloads docs dependency status

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));
    }
Commit count: 0

cargo fmt