Function and

Source
pub const fn and(
    a: impl Fn(Vector) -> Vector,
    b: impl Fn(Vector) -> Vector,
) -> impl Fn(Vector) -> Vector
Expand description

Combine two conditions

§Arguments

  • a - The lhs condition
  • b - The rhs condition

§Example

use swift_check::{ensure, range, eq, not, and, arch::load};

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

let is_num_but_not_5 = ensure!(data, and(range!(b'0'..=b'9'), not(eq(b'5'))));
assert!(is_num_but_not_5);

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

let should_fail = ensure!(data, and(range!(b'0'..=b'9'), not(eq(b'5'))));
assert!(!should_fail);