[−][src]Macro nom::preceded
preceded!(I -> IResult<I,T>, I -> IResult<I,O>) => I -> IResult<I, O>
preceded
returns the result of its second parser if both succeed.
named!(parser<&str, &str>, preceded!(char!('-'), alpha1)); assert_eq!(parser("-abc"), Ok(("", "abc"))); assert_eq!(parser("abc"), Err(Err::Error(Error::new("abc", ErrorKind::Char)))); assert_eq!(parser("-123"), Err(Err::Error(Error::new("123", ErrorKind::Alpha))));