macro_rules! assertable_io_le {
    ($left:expr, $right:expr $(,)?) => { ... };
    ($left:expr, $right:expr, $($arg:tt)+) => { ... };
}
Expand description

Assert one value is less than or equal to another value.

  • 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_le!(1, 2);
//-> Ok(())
assert!(x.is_ok());

let x = assertable_io_le!(2, 1);
//-> Err(std::io::Error::new(std::io::ErrorKind::InvalidInput, "…")
// assertable failed: `assertable_io_le!(left, right)`
//   left: `2`,
//  right: `1`
assert_eq!(
    x.unwrap_err().get_ref().unwrap().to_string(),
    "assertable failed: `assertable_io_le!(left, right)`\n  left: `2`,\n right: `1`"
);

This macro has a second form where a custom message can be provided.