From be68eabf91b2332a786ee23fe338019566165380 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 18 Oct 2024 10:16:03 -0700 Subject: [PATCH] Return error instead of Null if i128 deserialized to Value is out of range --- src/value/de.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/value/de.rs b/src/value/de.rs index c38253aff..3973ae794 100644 --- a/src/value/de.rs +++ b/src/value/de.rs @@ -44,9 +44,12 @@ impl<'de> Deserialize<'de> for Value { Ok(Value::Number(value.into())) } - #[inline] - fn visit_i128(self, value: i128) -> Result { - Ok(Number::from_i128(value).map_or(Value::Null, Value::Number)) + fn visit_i128(self, value: i128) -> Result + where + E: serde::de::Error, + { + let de = serde::de::value::I128Deserializer::new(value); + Number::deserialize(de).map(Value::Number) } #[inline]