From c76e3c3ec33ca1afa30516e0c479ea7811fed954 Mon Sep 17 00:00:00 2001 From: Qinxuan Chen Date: Mon, 2 Dec 2024 19:08:33 +0800 Subject: [PATCH] chore(ci): fix clippy warnings when using rust 1.83 (#1499) --- core/src/server/helpers.rs | 2 +- core/src/server/method_response.rs | 2 +- types/src/error.rs | 4 ++-- types/src/params.rs | 14 +++++++------- types/src/response.rs | 8 ++++---- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/core/src/server/helpers.rs b/core/src/server/helpers.rs index 0fcdd932cb..1135155d30 100644 --- a/core/src/server/helpers.rs +++ b/core/src/server/helpers.rs @@ -61,7 +61,7 @@ impl BoundedWriter { } } -impl<'a> io::Write for &'a mut BoundedWriter { +impl io::Write for &mut BoundedWriter { fn write(&mut self, buf: &[u8]) -> io::Result { let len = self.buf.len() + buf.len(); if self.max_len >= len { diff --git a/core/src/server/method_response.rs b/core/src/server/method_response.rs index 5981efa721..30b3e84ea8 100644 --- a/core/src/server/method_response.rs +++ b/core/src/server/method_response.rs @@ -394,7 +394,7 @@ where } } -impl<'a, T> From for ResponsePayload<'a, T> +impl From for ResponsePayload<'_, T> where T: Clone, { diff --git a/types/src/error.rs b/types/src/error.rs index d2152b2c54..4617e8e318 100644 --- a/types/src/error.rs +++ b/types/src/error.rs @@ -96,7 +96,7 @@ impl<'a> ErrorObject<'a> { } } -impl<'a> PartialEq for ErrorObject<'a> { +impl PartialEq for ErrorObject<'_> { fn eq(&self, other: &Self) -> bool { let this_raw = self.data.as_ref().map(|r| r.get()); let other_raw = other.data.as_ref().map(|r| r.get()); @@ -104,7 +104,7 @@ impl<'a> PartialEq for ErrorObject<'a> { } } -impl<'a> From for ErrorObject<'a> { +impl From for ErrorObject<'_> { fn from(code: ErrorCode) -> Self { Self { code, message: code.message().into(), data: None } } diff --git a/types/src/params.rs b/types/src/params.rs index db97147808..f2bd8e8fb0 100644 --- a/types/src/params.rs +++ b/types/src/params.rs @@ -44,7 +44,7 @@ pub struct TwoPointZero; struct TwoPointZeroVisitor; -impl<'de> Visitor<'de> for TwoPointZeroVisitor { +impl Visitor<'_> for TwoPointZeroVisitor { type Value = TwoPointZero; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { @@ -269,7 +269,7 @@ pub enum SubscriptionId<'a> { Str(Cow<'a, str>), } -impl<'a> From> for JsonValue { +impl From> for JsonValue { fn from(sub_id: SubscriptionId) -> Self { match sub_id { SubscriptionId::Num(n) => n.into(), @@ -278,13 +278,13 @@ impl<'a> From> for JsonValue { } } -impl<'a> From for SubscriptionId<'a> { +impl From for SubscriptionId<'_> { fn from(sub_id: u64) -> Self { Self::Num(sub_id) } } -impl<'a> From for SubscriptionId<'a> { +impl From for SubscriptionId<'_> { fn from(sub_id: String) -> Self { Self::Str(sub_id.into()) } @@ -308,7 +308,7 @@ impl<'a> TryFrom for SubscriptionId<'a> { } } -impl<'a> SubscriptionId<'a> { +impl SubscriptionId<'_> { /// Convert `SubscriptionId<'a>` to `SubscriptionId<'static>` so that it can be moved across threads. /// /// This can cause an allocation if the id is a string. @@ -350,7 +350,7 @@ pub enum Id<'a> { Str(Cow<'a, str>), } -impl<'a> Id<'a> { +impl Id<'_> { /// If the Id is a number, returns the associated number. Returns None otherwise. pub fn as_number(&self) -> Option<&u64> { match self { @@ -396,7 +396,7 @@ impl<'a> Id<'a> { } } -impl<'a> std::fmt::Display for Id<'a> { +impl std::fmt::Display for Id<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Id::Null => f.write_str("null"), diff --git a/types/src/response.rs b/types/src/response.rs index c576ffa04b..b5d6f3fb5e 100644 --- a/types/src/response.rs +++ b/types/src/response.rs @@ -59,7 +59,7 @@ impl<'a, T: Clone> Response<'a, T> { } } -impl<'a, T> fmt::Display for Response<'a, T> +impl fmt::Display for Response<'_, T> where T: Serialize + Clone, { @@ -68,7 +68,7 @@ where } } -impl<'a, T> fmt::Debug for Response<'a, T> +impl fmt::Debug for Response<'_, T> where T: Serialize + Clone, { @@ -205,7 +205,7 @@ where { struct FieldVisitor; - impl<'de> serde::de::Visitor<'de> for FieldVisitor { + impl serde::de::Visitor<'_> for FieldVisitor { type Value = Field; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { @@ -313,7 +313,7 @@ where } } -impl<'a, T> Serialize for Response<'a, T> +impl Serialize for Response<'_, T> where T: Serialize + Clone, {