From 8c32ff6324f93876aba090d1f1519cd2d728179b Mon Sep 17 00:00:00 2001 From: Pascal Seitz Date: Mon, 28 Oct 2024 10:26:53 +0800 Subject: [PATCH] clippy --- src/deserializer.rs | 4 ++-- src/ser.rs | 4 ++-- src/value.rs | 22 +++++++++++----------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/deserializer.rs b/src/deserializer.rs index 2e6756c..e1adcaf 100644 --- a/src/deserializer.rs +++ b/src/deserializer.rs @@ -4,7 +4,7 @@ use serde::Deserializer; use crate::value::N; use crate::{KeyStrType, Value}; -impl<'de, 'ctx> IntoDeserializer<'de, de::value::Error> for &'de Value<'ctx> { +impl<'de> IntoDeserializer<'de, de::value::Error> for &'de Value<'_> { type Deserializer = Self; fn into_deserializer(self) -> Self::Deserializer { @@ -12,7 +12,7 @@ impl<'de, 'ctx> IntoDeserializer<'de, de::value::Error> for &'de Value<'ctx> { } } -impl<'ctx, 'de> Deserializer<'de> for &'de Value<'ctx> { +impl<'de> Deserializer<'de> for &'de Value<'_> { type Error = de::value::Error; fn deserialize_any(self, visitor: V) -> Result diff --git a/src/ser.rs b/src/ser.rs index ef9aef8..1ffd0f8 100644 --- a/src/ser.rs +++ b/src/ser.rs @@ -4,7 +4,7 @@ use crate::owned::OwnedValue; use crate::value::{Number, Value, N}; use crate::Map; -impl<'ctx> Serialize for Value<'ctx> { +impl Serialize for Value<'_> { fn serialize(&self, serializer: S) -> Result where S: Serializer { match self { @@ -17,7 +17,7 @@ impl<'ctx> Serialize for Value<'ctx> { } } } -impl<'ctx> Serialize for Map<'ctx> { +impl Serialize for Map<'_> { fn serialize(&self, serializer: S) -> Result where S: Serializer { serializer.collect_map(self.iter()) diff --git a/src/value.rs b/src/value.rs index d9344d2..688abeb 100644 --- a/src/value.rs +++ b/src/value.rs @@ -244,7 +244,7 @@ impl<'ctx> Value<'ctx> { } } -impl<'a> From for Value<'a> { +impl From for Value<'_> { fn from(val: bool) -> Self { Value::Bool(val) } @@ -256,7 +256,7 @@ impl<'a> From<&'a str> for Value<'a> { } } -impl<'a> From for Value<'a> { +impl From for Value<'_> { fn from(val: String) -> Self { Value::Str(Cow::Owned(val)) } @@ -274,7 +274,7 @@ impl<'a, T: Clone + Into>> From<&[T]> for Value<'a> { } } -impl<'ctx> Debug for Value<'ctx> { +impl Debug for Value<'_> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { match self { Value::Null => formatter.write_str("Null"), @@ -339,7 +339,7 @@ impl Number { pub fn as_i64(&self) -> Option { match self.n { N::PosInt(n) => { - if n <= i64::max_value() as u64 { + if n <= i64::MAX as u64 { Some(n as i64) } else { None @@ -373,7 +373,7 @@ impl Number { /// `i64::MAX`. pub fn is_i64(&self) -> bool { match self.n { - N::PosInt(v) => v <= i64::max_value() as u64, + N::PosInt(v) => v <= i64::MAX as u64, N::NegInt(_) => true, N::Float(_) => false, } @@ -413,19 +413,19 @@ impl Hash for N { } } -impl<'a> From for Value<'a> { +impl From for Value<'_> { fn from(val: u64) -> Self { Value::Number(val.into()) } } -impl<'a> From for Value<'a> { +impl From for Value<'_> { fn from(val: i64) -> Self { Value::Number(val.into()) } } -impl<'a> From for Value<'a> { +impl From for Value<'_> { fn from(val: f64) -> Self { Value::Number(val.into()) } @@ -459,7 +459,7 @@ impl From for serde_json::value::Number { } } -impl<'ctx> From> for serde_json::Value { +impl From> for serde_json::Value { fn from(val: Value) -> Self { match val { Value::Null => serde_json::Value::Null, @@ -474,7 +474,7 @@ impl<'ctx> From> for serde_json::Value { } } -impl<'ctx> From<&Value<'ctx>> for serde_json::Value { +impl From<&Value<'_>> for serde_json::Value { fn from(val: &Value) -> Self { match val { Value::Null => serde_json::Value::Null, @@ -515,7 +515,7 @@ impl<'ctx> From<&'ctx serde_json::Value> for Value<'ctx> { for (k, v) in obj { ans.insert(k.as_str(), v.into()); } - Value::Object(ObjectAsVec::from(ans)) + Value::Object(ans) } } }