From b277aa1aceee7e3ceef33e8206db4b3b5b1195ce Mon Sep 17 00:00:00 2001 From: Geoffroy Couprie Date: Fri, 26 Jul 2024 21:13:41 +0200 Subject: [PATCH] test byte conversion --- src/number/mod.rs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/number/mod.rs b/src/number/mod.rs index 9e7e3d7e..e406569e 100644 --- a/src/number/mod.rs +++ b/src/number/mod.rs @@ -12,7 +12,7 @@ use crate::{ error::{make_error, ErrorKind, ParseError}, sequence::pair, AsBytes, AsChar, Compare, Either, Emit, Err, Input, IsStreaming, Mode, Needed, Offset, OutputM, - Parser, + OutputMode, Parser, }; pub mod complete; @@ -1397,8 +1397,23 @@ where &mut self, input: I, ) -> crate::PResult { - let (i, s) = - recognize_float_or_exceptions().process::>(input)?; + let inp = input.clone(); + let (_, s) = recognize_float_or_exceptions() + .process::>(inp.as_bytes()) + .map_err( + |e: crate::Err<(), <::Error as Mode>::Output<()>>| match e { + Err::Incomplete(i) => Err::Incomplete(i), + Err::Error(_) => Err::Error(OM::Error::bind(|| { + E::from_error_kind(input.clone(), crate::error::ErrorKind::Float) + })), + Err::Failure(_) => Err::Failure(E::from_error_kind( + input.clone(), + crate::error::ErrorKind::Float, + )), + }, + )?; + let recognized_length = s.len(); + let (i, s) = input.take_split(recognized_length); match s.parse_to() { Some(f) => Ok((i, OM::Output::bind(|| f))),