Macro assertables::assertable_io
source · [−]macro_rules! assertable_io {
($x:expr $(,)?) => { ... };
($x:expr, $($arg:tt)+) => { ... };
}
Expand description
Assert a condition is true.
-
When true, return
Ok(())
. -
Otherwise, return
Err
with a message and the values of the expressions with their debug representations.
Examples
let x = assertable_io!(true);
//-> Ok(())
assert!(x.is_ok());
let x = assertable_io!(false);
//-> Err(std::io::Error::new(std::io::ErrorKind::InvalidInput, "…");
// assertable failed: `assertable_io(condition) condition: `false`
assert_eq!(
x.unwrap_err().get_ref().unwrap().to_string(),
"assertable failed: `assertable_io(condition) condition: `false`"
);
This macro has a second form where a custom message can be provided.