macro_rules! truthy {
( ! $( $tokens:tt )+ ) => { ... };
( ( $( $tokens:tt )+ ) ) => { ... };
( ( $( $tokens:tt )+ ) && $( $remainder:tt )+ ) => { ... };
( ( $( $tokens:tt )+ ) || $( $remainder:tt )+ ) => { ... };
( $i:ident ) => { ... };
( $i:ident && $($remainder:tt)+ ) => { ... };
( $i:ident || $($remainder:tt)+ ) => { ... };
}
Convenience macro for evaluating truthiness.
Helps avoid repeatedly typing .truthy()
in a long boolean chain.
assert_eq!(x.truthy() && (y.truthy() || !z.truthy()), truthy!(x && (y || !z)));