Macro nom::flat_map[][src]

macro_rules! flat_map {
    ($i : expr, $submac : ident! ($($args : tt) *), $submac2 : ident!
 ($($args2 : tt) *)) => { ... };
    ($i : expr, $submac : ident! ($($args : tt) *), $g : expr) => { ... };
    ($i : expr, $f : expr, $submac : ident! ($($args : tt) *)) => { ... };
    ($i : expr, $f : expr, $g : expr) => { ... };
    (__impl $i : expr, $submac : ident! ($($args : tt) *), $submac2 : ident!
 ($($args2 : tt) *)) => { ... };
}
Expand description

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

combines a parser R -> IResult<R,S> and a parser S -> IResult<S,T> to return another parser R -> IResult<R,T>

use nom::number::complete::recognize_float;

named!(parser<&str, f64>, flat_map!(recognize_float, parse_to!(f64)));

assert_eq!(parser("123.45;"), Ok((";", 123.45)));
assert_eq!(parser("abc"), Err(Err::Error(("abc", ErrorKind::Char))));