Macro gazebo::eq_chain [−][src]
macro_rules! eq_chain {
($e : expr) => { ... };
($e : expr, $($x : expr), + $(,) ?) => { ... };
}
Expand description
Performs a chain of equals operation expressions yielding bool
, supporting
early exit upon hitting the first expressions that returns false
and returning false
.
This is useful for easily writing a sequence of equals expressions necessary to yield a bool
The macro is expanded inplace, so any expressions dealing with Result
types are allowed
provided that the larger scope allows returning result.
use gazebo::eq_chain;
assert_eq!(
eq_chain! {
1 == 1,
Ok::<_, ()>(2 == 2)?,
3 == 4,
panic!("won't reach this"),
},
false,
);