Macro nom::tap
[−]
[src]
macro_rules! tap { ($i:expr, $name:ident : $submac:ident!( $($args:tt)* ) => $e:expr) => { ... }; ($i:expr, $name: ident: $f:expr => $e:expr) => { ... }; }
tap!(name: I -> IResult<I,O> => { block }) => I -> IResult<I, O>
allows access to the parser's result without affecting it
named!(ptag, tap!(res: tag!( "abcd" ) => { println!("recognized {}", str::from_utf8(res).unwrap()) } ) ); let r = ptag(&b"abcdefgh"[..]); assert_eq!(r, Ok((&b"efgh"[..], &b"abcd"[..])));