18 lines
480 B
Rust
18 lines
480 B
Rust
use hyperscan::prelude::*;
|
|
|
|
fn main() {
|
|
let pattern = pattern! {"test"; CASELESS | SOM_LEFTMOST};
|
|
let db: BlockDatabase = pattern.build().unwrap();
|
|
let scratch = db.alloc_scratch().unwrap();
|
|
let mut matches = vec![];
|
|
|
|
db.scan("some test data", &scratch, |id, from, to, _flags| {
|
|
println!("found pattern #{} @ [{}, {})", id, from, to);
|
|
|
|
matches.push(from..to);
|
|
|
|
Matching::Continue
|
|
}).unwrap();
|
|
|
|
assert_eq!(matches, vec![5..9]);
|
|
} |