Skip to content

Commit

Permalink
Update lexical-core version to "^0.6".
Browse files Browse the repository at this point in the history
Patches:
- #1100
- #1080
- #1066
- And a few upstream issues.
  • Loading branch information
Alexhuszagh authored and Geal committed Feb 24, 2020
1 parent de22438 commit 2a19903
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 40 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ version = "^2.0"
default-features = false

[dependencies.lexical-core]
version = "^0.4.0"
version = "^0.6.0"
optional = true

[dev-dependencies]
Expand Down
26 changes: 6 additions & 20 deletions src/number/complete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -832,16 +832,9 @@ pub fn float<T, E:ParseError<T>>(input: T) -> IResult<T, f32, E>
where
T: crate::traits::AsBytes + InputLength + Slice<RangeFrom<usize>>,
{
let res = ::lexical_core::try_atof32_slice(input.as_bytes());

match res.error.code {
::lexical_core::ErrorCode::Success => Ok((input.slice(input.input_len()..), res.value)),
::lexical_core::ErrorCode::InvalidDigit => if res.error.index == 0 {
Err(Err::Error(E::from_error_kind(input, ErrorKind::Float)))
} else {
Ok((input.slice(res.error.index..), res.value))
},
_ => Err(Err::Error(E::from_error_kind(input, ErrorKind::Float))),
match ::lexical_core::parse_partial(input.as_bytes()) {
Ok((value, processed)) => Ok((input.slice(processed..), value)),
Err(_) => Err(Err::Error(E::from_error_kind(input, ErrorKind::Float)))
}
}

Expand Down Expand Up @@ -906,16 +899,9 @@ pub fn double<T, E:ParseError<T>>(input: T) -> IResult<T, f64, E>
where
T: crate::traits::AsBytes + InputLength + Slice<RangeFrom<usize>>,
{
let res = ::lexical_core::try_atof64_slice(input.as_bytes());

match res.error.code {
::lexical_core::ErrorCode::Success => Ok((input.slice(input.input_len()..), res.value)),
::lexical_core::ErrorCode::InvalidDigit => if res.error.index == 0 {
Err(Err::Error(E::from_error_kind(input, ErrorKind::Float)))
} else {
Ok((input.slice(res.error.index..), res.value))
},
_ => Err(Err::Error(E::from_error_kind(input, ErrorKind::Float))),
match ::lexical_core::parse_partial(input.as_bytes()) {
Ok((value, processed)) => Ok((input.slice(processed..), value)),
Err(_) => Err(Err::Error(E::from_error_kind(input, ErrorKind::Float)))
}
}

Expand Down
32 changes: 13 additions & 19 deletions src/number/streaming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -829,18 +829,15 @@ pub fn float<T, E:ParseError<T>>(input: T) -> IResult<T, f32, E>
where
T: crate::traits::AsBytes + InputLength + Slice<RangeFrom<usize>>,
{
let res = ::lexical_core::try_atof32_slice(input.as_bytes());

match res.error.code {
::lexical_core::ErrorCode::Success => Err(Err::Incomplete(Needed::Unknown)),
::lexical_core::ErrorCode::InvalidDigit => {
if res.error.index == 0 {
Err(Err::Error(E::from_error_kind(input, ErrorKind::Float)))
match ::lexical_core::parse_partial(input.as_bytes()) {
Ok((value, processed)) => {
if (processed == input.input_len()) {
Err(Err::Incomplete(Needed::Unknown))
} else {
Ok((input.slice(res.error.index..), res.value))
Ok((input.slice(processed..), value))
}
},
_ => Err(Err::Error(E::from_error_kind(input, ErrorKind::Float))),
Err(_) => Err(Err::Error(E::from_error_kind(input, ErrorKind::Float)))
}
}

Expand Down Expand Up @@ -905,18 +902,15 @@ pub fn double<T, E:ParseError<T>>(input: T) -> IResult<T, f64, E>
where
T: crate::traits::AsBytes + InputLength + Slice<RangeFrom<usize>>,
{
let res = ::lexical_core::try_atof64_slice(input.as_bytes());

match res.error.code {
::lexical_core::ErrorCode::Success => Err(Err::Incomplete(Needed::Unknown)),
::lexical_core::ErrorCode::InvalidDigit => {
if res.error.index == 0 {
Err(Err::Error(E::from_error_kind(input, ErrorKind::Float)))
match ::lexical_core::parse_partial(input.as_bytes()) {
Ok((value, processed)) => {
if (processed == input.input_len()) {
Err(Err::Incomplete(Needed::Unknown))
} else {
Ok((input.slice(res.error.index..), res.value))
Ok((input.slice(processed..), value))
}
}
_ => Err(Err::Error(E::from_error_kind(input, ErrorKind::Float))),
},
Err(_) => Err(Err::Error(E::from_error_kind(input, ErrorKind::Float)))
}
}

Expand Down

0 comments on commit 2a19903

Please sign in to comment.