Function rocket::mtls::x509::der_parser::asn1_rs::nom::number::streaming::double

source ·
pub fn double<T, E>(input: T) -> Result<(T, f64), Err<E>>
Available on crate feature mtls only.
Expand description

Recognizes floating point number in text format and returns a f64.

Streaming version: Will return Err(nom::Err::Incomplete(_)) if there is not enough data.

use nom::number::complete::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))));