From 3f4b73531e345fde178b6a397c257d6b5067fe93 Mon Sep 17 00:00:00 2001 From: Anatoly Ikorsky Date: Sat, 7 Dec 2024 15:58:47 +0300 Subject: [PATCH] clippy --- src/collations.rs | 2 +- src/misc/raw/seq.rs | 6 ++--- src/packets/caching_sha2_password.rs | 6 +++++ src/packets/mod.rs | 34 +++++++++++++++++----------- src/packets/session_state_change.rs | 2 +- src/row/mod.rs | 2 +- src/value/convert/mod.rs | 2 +- 7 files changed, 34 insertions(+), 20 deletions(-) diff --git a/src/collations.rs b/src/collations.rs index 49d0f9d..1a18638 100644 --- a/src/collations.rs +++ b/src/collations.rs @@ -648,7 +648,7 @@ pub struct Collation<'a> { /// JOIN INFORMATION_SCHEMA.CHARACTER_SETS /// USING(CHARACTER_SET_NAME) ORDER BY ID; /// ``` -impl<'a> Collation<'a> { +impl Collation<'_> { /// This is a stub. const UNKNOWN_COLLATION: Collation<'static> = Collation { id: CollationId::UNKNOWN_COLLATION_ID, diff --git a/src/misc/raw/seq.rs b/src/misc/raw/seq.rs index 078752e..deb9610 100644 --- a/src/misc/raw/seq.rs +++ b/src/misc/raw/seq.rs @@ -25,7 +25,7 @@ use super::{ #[repr(transparent)] pub struct Seq<'a, T: Clone, U>(pub Cow<'a, [T]>, PhantomData); -impl<'a, T: Clone, U> Deref for Seq<'a, T, U> { +impl Deref for Seq<'_, T, U> { type Target = [T]; fn deref(&self) -> &Self::Target { @@ -68,7 +68,7 @@ impl<'a, T: Clone, U> Seq<'a, T, U> { } } -impl<'a, T: Clone, U> Default for Seq<'a, T, U> { +impl Default for Seq<'_, T, U> { fn default() -> Self { Seq::new(Vec::new()) } @@ -185,7 +185,7 @@ impl<'a, T: IntRepr, U> RawSeq<'a, T, U> { } } -impl<'a, T: IntRepr, U> RawSeq<'a, T, U> +impl RawSeq<'_, T, U> where T: Copy, U: TryFrom, diff --git a/src/packets/caching_sha2_password.rs b/src/packets/caching_sha2_password.rs index 5c2e11e..cac4196 100644 --- a/src/packets/caching_sha2_password.rs +++ b/src/packets/caching_sha2_password.rs @@ -28,6 +28,12 @@ impl PublicKeyRequest { } } +impl Default for PublicKeyRequest { + fn default() -> Self { + Self::new() + } +} + impl<'de> MyDeserialize<'de> for PublicKeyRequest { const SIZE: Option = None; type Ctx = (); diff --git a/src/packets/mod.rs b/src/packets/mod.rs index 6ed529e..989a5b3 100644 --- a/src/packets/mod.rs +++ b/src/packets/mod.rs @@ -120,7 +120,7 @@ struct ColumnMeta<'a> { org_name: RawBytes<'a, LenEnc>, } -impl<'a> ColumnMeta<'a> { +impl ColumnMeta<'_> { pub fn into_owned(self) -> ColumnMeta<'static> { ColumnMeta { schema: self.schema.into_owned(), @@ -428,7 +428,7 @@ pub struct SessionStateInfo<'a> { data: RawBytes<'a, LenEnc>, } -impl<'a> SessionStateInfo<'a> { +impl SessionStateInfo<'_> { pub fn into_owned(self) -> SessionStateInfo<'static> { let SessionStateInfo { data_type, data } = self; SessionStateInfo { @@ -678,7 +678,7 @@ pub struct OkPacket<'a> { session_state_info: Option>, } -impl<'a> OkPacket<'a> { +impl OkPacket<'_> { pub fn into_owned(self) -> OkPacket<'static> { OkPacket { affected_rows: self.affected_rows, @@ -864,7 +864,7 @@ impl MySerialize for ProgressReport<'_> { } } -impl<'a> fmt::Display for ProgressReport<'a> { +impl fmt::Display for ProgressReport<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!( f, @@ -892,7 +892,7 @@ pub enum ErrPacket<'a> { Progress(ProgressReport<'a>), } -impl<'a> ErrPacket<'a> { +impl ErrPacket<'_> { /// Returns false if this error packet contains progress report. pub fn is_error(&self) -> bool { matches!(self, ErrPacket::Error { .. }) @@ -957,7 +957,7 @@ impl MySerialize for ErrPacket<'_> { } } -impl<'a> fmt::Display for ErrPacket<'a> { +impl fmt::Display for ErrPacket<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { ErrPacket::Error(server_error) => write!(f, "{}", server_error), @@ -1190,7 +1190,7 @@ pub enum AuthPluginData<'a> { Clear(Cow<'a, [u8]>), } -impl<'a> AuthPluginData<'a> { +impl AuthPluginData<'_> { pub fn into_owned(self) -> AuthPluginData<'static> { match self { AuthPluginData::Old(x) => AuthPluginData::Old(x), @@ -1667,6 +1667,7 @@ impl MySerialize for HandshakePacket<'_> { } impl<'a> HandshakePacket<'a> { + #[allow(clippy::too_many_arguments)] pub fn new( protocol_version: u8, server_version: impl Into>, @@ -1898,6 +1899,12 @@ impl<'a> ComChangeUser<'a> { } } +impl Default for ComChangeUser<'_> { + fn default() -> Self { + Self::new() + } +} + impl<'de> MyDeserialize<'de> for ComChangeUser<'de> { const SIZE: Option = None; @@ -2042,7 +2049,7 @@ impl<'de> MyDeserialize<'de> for ComChangeUserMoreData<'de> { } } -impl<'a> MySerialize for ComChangeUserMoreData<'a> { +impl MySerialize for ComChangeUserMoreData<'_> { fn serialize(&self, buf: &mut Vec) { self.character_set.serialize(&mut *buf); if let Some(ref auth_plugin) = self.auth_plugin { @@ -2075,6 +2082,7 @@ pub struct HandshakeResponse<'a> { } impl<'a> HandshakeResponse<'a> { + #[allow(clippy::too_many_arguments)] pub fn new( scramble_buf: Option>>, server_version: (u16, u16, u16), @@ -2789,7 +2797,7 @@ impl<'a> ComRegisterSlave<'a> { } /// Returns the raw `hostname` field value. - pub fn hostname_raw(&'a self) -> &[u8] { + pub fn hostname_raw(&self) -> &[u8] { self.hostname.as_bytes() } @@ -2799,7 +2807,7 @@ impl<'a> ComRegisterSlave<'a> { } /// Returns the raw `user` field value. - pub fn user_raw(&'a self) -> &[u8] { + pub fn user_raw(&self) -> &[u8] { self.user.as_bytes() } @@ -2809,7 +2817,7 @@ impl<'a> ComRegisterSlave<'a> { } /// Returns the raw `password` field value. - pub fn password_raw(&'a self) -> &[u8] { + pub fn password_raw(&self) -> &[u8] { self.password.as_bytes() } @@ -3140,7 +3148,7 @@ pub struct Sid<'a> { intervals: Seq<'a, GnoInterval, LeU64>, } -impl<'a> Sid<'a> { +impl Sid<'_> { /// Creates a new instance. pub fn new(uuid: [u8; UUID_LEN]) -> Self { Self { @@ -3217,7 +3225,7 @@ impl Sid<'_> { } } -impl<'a> FromStr for Sid<'a> { +impl FromStr for Sid<'_> { type Err = io::Error; fn from_str(s: &str) -> Result { diff --git a/src/packets/session_state_change.rs b/src/packets/session_state_change.rs index c918f95..dedf4c7 100644 --- a/src/packets/session_state_change.rs +++ b/src/packets/session_state_change.rs @@ -31,7 +31,7 @@ pub enum SessionStateChange<'a> { Unsupported(Unsupported<'a>), } -impl<'a> SessionStateChange<'a> { +impl SessionStateChange<'_> { pub fn into_owned(self) -> SessionStateChange<'static> { match self { SessionStateChange::SystemVariables(x) => SessionStateChange::SystemVariables( diff --git a/src/row/mod.rs b/src/row/mod.rs index 3288ffc..3d370d6 100644 --- a/src/row/mod.rs +++ b/src/row/mod.rs @@ -213,7 +213,7 @@ impl ColumnIndex for usize { } } -impl<'a> ColumnIndex for &'a str { +impl ColumnIndex for &'_ str { fn idx(&self, columns: &[Column]) -> Option { for (i, c) in columns.iter().enumerate() { if c.name_ref() == self.as_bytes() { diff --git a/src/value/convert/mod.rs b/src/value/convert/mod.rs index eef54b1..725fc8d 100644 --- a/src/value/convert/mod.rs +++ b/src/value/convert/mod.rs @@ -44,7 +44,7 @@ lazy_static::lazy_static! { } /// Returns (year, month, day, hour, minute, second, micros) -#[cfg(any(feature = "chrono"))] +#[cfg(feature = "chrono")] fn parse_mysql_datetime_string(bytes: &[u8]) -> Option<(u32, u32, u32, u32, u32, u32, u32)> { let len = bytes.len();