Macro assert_in_range

Source
macro_rules! assert_in_range {
    ($a:expr, $range:expr $(,)?) => { ... };
    ($a:expr, $range:expr, $($message:tt)+) => { ... };
}
Expand description

Assert an item is in a range.

Pseudocode:
a is in range

  • If true, return ().

  • Otherwise, call panic! with a message and the values of the expressions with their debug representations.

§Examples

use assertables::*;

let a = 1;
let b = 0..2;
assert_in_range!(a, b);

// This will panic
let a = 1;
let b = 2..4;
assert_in_range!(a, b);
// assertion failed: `assert_in_range!(a, range)`
// https://docs.rs/assertables/…/assertables/macro.assert_in_range.html
//  a label: `a`,
//  a debug: `1`,
//  range label: `b`,
//  range debug: `2..4`

§Module macros