Macro swift_check::ensure

source ·
macro_rules! ensure {
    ($data:expr, $cond:expr) => { ... };
}
Expand description

Check that the condition holds for all bytes

§Arguments

  • data - The Vector to check each element of
  • cond - The condition to check

§Example

use swift_check::{ensure, any, eq, arch::load};

let input = b"2112111211211211";
let data = load(input);

let two_or_one = ensure!(data, any!(eq(b'1'), eq(b'2')));
assert!(two_or_one);

let should_fail = ensure!(data, eq(b'1'));
assert!(!should_fail);

Note: This is part of the lower level api, for better ergonomics see for_all_ensure.