Macro utils::ensure

source ยท
macro_rules! ensure {
    ($condition:expr) => { ... };
    ($condition:expr, $message:literal) => { ... };
    ($condition:expr, $fmt:expr, $($arg:tt)*) => { ... };
    ($condition:expr, $error:expr) => { ... };
}
Expand description

Check that the given condition holds, otherwise return an error.

The argument can be either:

  • a condition, in which case a generic error is logged at the Unspecified level.
  • a condition and a string literal, in which case the provided literal is logged at the Unspecified level.
  • a condition and a format expression, in which case the message is formatted and logged at the Unspecified level.
  • a condition and an Error, in which case the given error is logged unchanged.