Hitori is a generic regular expressions library. It works by creating series of if-statements for each expression at compile-time. Capturing is done through the traits.
```rust struct Let { max: u32, }
impl
let text = "... let x = 5.1; ...";
let mut capture = LetCaptureRanges::default(); let found = hitori::string::find(Let { max: 6 }, &mut capture, text) .unwrap() .unwrap(); asserteq!(&text[found], "let x = 5.1;"); asserteq!(&text[capture.var.unwrap()], "x"); assert_eq!(&text[capture.val.unwrap()], "5.1");
let notfound = hitori::string::findnocapture(Let { max: 4 }, text); asserteq!(not_found, None); ```
See more code samples along with the traits, impls and struct they expand to in examples
.
box
(enabled by default) – blanket implementations of all traits for boxes using alloc crate.macros
(enabled by default) – impl_expr_mut
and impl_expr
macros.find-hitori
– finds hitori package to be used in macros even if it has been renamed in Cargo.toml. macros
feature is required.Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.