Skip to main content

ensure

Macro ensure 

Source
macro_rules! ensure {
    ($cond:expr, $variant:ident { $($field:ident : $val:expr),* $(,)? }) => { ... };
    ($cond:expr, $variant:ident) => { ... };
    ($cond:expr, $err:expr) => { ... };
}
Expand description

Ensures that a condition is true, returning an error if it is not.

This macro provides a convenient way to validate preconditions and invariants within [QueueFile] methods.

ยงVariants

  • ensure!(condition, VariantName { field: value }) - creates error with fields
  • ensure!(condition, VariantName) - creates error with no fields
  • ensure!(condition, expression) - uses the provided expression as error