Skip to content

Commit

Permalink
Merge pull request #1203 from dtolnay/i128err
Browse files Browse the repository at this point in the history
Return error instead of Null if i128 deserialized to Value is out of range
  • Loading branch information
dtolnay authored Oct 18, 2024
2 parents 95f55f3 + be68eab commit 7e45e3d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/value/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ impl<'de> Deserialize<'de> for Value {
Ok(Value::Number(value.into()))
}

#[inline]
fn visit_i128<E>(self, value: i128) -> Result<Value, E> {
Ok(Number::from_i128(value).map_or(Value::Null, Value::Number))
fn visit_i128<E>(self, value: i128) -> Result<Value, E>
where
E: serde::de::Error,
{
let de = serde::de::value::I128Deserializer::new(value);
Number::deserialize(de).map(Value::Number)
}

#[inline]
Expand Down

0 comments on commit 7e45e3d

Please sign in to comment.