Skip to content

Commit

Permalink
Return error instead of Null if i128 deserialized to Value is out of …
Browse files Browse the repository at this point in the history
…range
  • Loading branch information
dtolnay committed Oct 18, 2024
1 parent 95f55f3 commit be68eab
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 be68eab

Please sign in to comment.