Function linkspace::abe::lk_tokenize_abe
source · pub fn lk_tokenize_abe<'o>(
expr: &'o str,
exclude_ctr: &[u8],
per_comp: impl FnMut(u8, bool, &'o str) -> bool
) -> LkResult<()>
Expand description
An abe parser. Useful to split a cli argument like ’domain:[#:test]:/thing/[12/u32] correctly. The callback is called with (ctrl, contains_brackets, bytes ) where ctrl is 0 | ‘:’ | ‘/’ Only the first ctrl can be ‘\0’.
let mut v = vec![];
lk_tokenize_abe("this:is/the:example[::]\n[::]newline[:/]",b"/",|expr,has_brackets,ctr| { v.push((expr,has_brackets,ctr)); true} );
assert_eq!(v,&[(0,false,"this"), (b':',false,"is/the"), (b':',true,"example[::]"),(b'\n',true,"[::]newline[:/]")])