Macro swift_check::find
source · macro_rules! find { ($data:expr, $cond:expr) => { ... }; }
Expand description
Find the first circumstance of the condition being met
§Arguments
data
- TheVector
to searchcond
- The condition to find
§Example
use swift_check::{arch::load, find, eq};
let input = b"aaaaaaaaaaaaaaaB";
let data = load(input);
if let Some(position) = find!(data, eq(b'B')) {
assert_eq!(position as usize, input.len() - 1);
} else {
unreachable!("B is within the data");
}
Note: This is part of the lower level api, for better ergonomics see search
.