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

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

Recognizes a floating point number in text format and returns the corresponding part of the input.

Streaming version: Will return Err(nom::Err::Incomplete(_)) if it reaches the end of input.

use nom::number::streaming::recognize_float;

let parser = |s| {
  recognize_float(s)
};

assert_eq!(parser("11e-1;"), Ok((";", "11e-1")));
assert_eq!(parser("123E-02;"), Ok((";", "123E-02")));
assert_eq!(parser("123K-01"), Ok(("K-01", "123")));
assert_eq!(parser("abc"), Err(Err::Error(("abc", ErrorKind::Char))));