nom::value [] [src]

macro_rules! value {
    ($i:expr, $res:expr, $submac:ident!( $($args:tt)* )) => { ... };
    ($i:expr, $res:expr, $f:expr) => { ... };
    ($i:expr, $res:expr) => { ... };
}

value!(T, R -> IResult<R, S> ) => R -> IResult<R, T>

or value!(T) => R -> IResult<R, T>

If the child parser was successful, return the value. If no child parser is provided, always return the value

 named!(x<u8>, value!(42, delimited!(tag!("<!--"), take!(5), tag!("-->"))));
 named!(y<u8>, delimited!(tag!("<!--"), value!(42), tag!("-->")));
 let r = x(&b"<!-- abc --> aaa"[..]);
 assert_eq!(r, Done(&b" aaa"[..], 42));

 let r2 = y(&b"<!----> aaa"[..]);
 assert_eq!(r2, Done(&b" aaa"[..], 42));