pub trait NeuCond<'a, C>where
C: Context<'a>,{
// Required method
fn check(&self, ctx: &C, item: &(usize, C::Item)) -> Result<bool, Error>;
}Required Methods§
Implementors§
impl<'a, C> NeuCond<'a, C> for NullCondwhere C: Context<'a>,
impl<'a, C, F> NeuCond<'a, C> for Fwhere C: Context<'a>, F: Fn(&C, &(usize, <C as Context<'a>>::Item)) -> Result<bool, Error>,
Check the condition when match.
let str = neu::not(b'"')
.repeat_one_more()
// avoid match escape sequence
.set_cond(|ctx: &BytesCtx, (item_offset, _item): &(usize, u8)| {
Ok(!ctx.orig_at(ctx.offset() + item_offset)?.starts_with(b"\\\""))
})
// match the escape sequence in another regex
.or(b"\\\"")
.repeat(1..)
.pat();
let mut ctx = BytesCtx::new(br#""Hello world from \"rust\"!""#);
assert_eq!(ctx.try_mat(&str.quote(b"\"", b"\""))?, Span::new(0, 28));
Ok(())