Function nom::number::complete::float [−][src]
pub fn float<T, E: ParseError<T>>(input: T) -> IResult<T, f32, E> where
T: AsBytes + InputLength + Slice<RangeFrom<usize>>,
Recognizes floating point number in a byte string and returns a f32.
Complete version: Can parse until the end of input.
This function uses the lexical-core
crate for float parsing by default, you
can deactivate it by removing the "lexical" feature.
use nom::number::complete::float; let parser = |s| { float(s) }; assert_eq!(parser("1.1"), Ok(("", 1.1))); assert_eq!(parser("123E-02"), Ok(("", 1.23))); assert_eq!(parser("123K-01"), Ok(("K-01", 123.0))); assert_eq!(parser("abc"), Err(Err::Error(("abc", ErrorKind::Float))));