pub fn ensure(data: Vector, cond: impl Fn(Vector) -> Vector) -> bool
Expand description
Check that the condition holds for all bytes
§Arguments
data
- TheVector
to check each element ofcond
- The condition to check
§Returns
true
if the cond
was satisfied for each byte, false
otherwise.
§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
or
for_all_ensure_ct
if branching on the data’s contents is unacceptable for security reasons.