[−][src]Function gchemol_parser::parsers::streaming::double
pub fn double<T, E>(input: T) -> Result<(T, f64), Err<E>> where
E: ParseError<T>,
T: AsBytes + InputLength + Slice<RangeFrom<usize>>,
Recognizes floating point number in a byte string and returns a f64
streaming version: will return Err(nom::Err::Incomplete(_))
if it reaches the end of input
use nom::number::streaming::double; let parser = |s| { double(s) }; assert_eq!(parser("11e-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))));
this function uses the lexical-core crate for float parsing by default, you can deactivate it by removing the "lexical" feature