Function winnow::number::streaming::double

source ·
pub fn double<T, E: ParseError<T>>(input: T) -> IResult<T, f64, E>where
    T: Stream + Offset + Compare<&'static str> + AsBStr,
    <T as Stream>::Slice: ParseSlice<f64>,
    <T as Stream>::Token: AsChar + Copy,
    <T as Stream>::IterOffsets: Clone,
👎Deprecated since 0.1.0: Replaced with <code>winnow::character::float</code> with input wrapped in <code>winnow::Partial</code>
Expand description

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

Partial version: Will return Err(winnow::error::ErrMode::Incomplete(_)) if there is not enough data.

use winnow::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(ErrMode::Backtrack(Error::new("abc", ErrorKind::Float))));

WARNING: Deprecated, replaced with winnow::character::float with input wrapped in winnow::Partial