Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
blackbeam committed Dec 7, 2024
1 parent e9566e9 commit 3f4b735
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/collations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/misc/raw/seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use super::{
#[repr(transparent)]
pub struct Seq<'a, T: Clone, U>(pub Cow<'a, [T]>, PhantomData<U>);

impl<'a, T: Clone, U> Deref for Seq<'a, T, U> {
impl<T: Clone, U> Deref for Seq<'_, T, U> {
type Target = [T];

fn deref(&self) -> &Self::Target {
Expand Down Expand Up @@ -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<T: Clone, U> Default for Seq<'_, T, U> {
fn default() -> Self {
Seq::new(Vec::new())
}
Expand Down Expand Up @@ -185,7 +185,7 @@ impl<'a, T: IntRepr, U> RawSeq<'a, T, U> {
}
}

impl<'a, T: IntRepr, U> RawSeq<'a, T, U>
impl<T: IntRepr, U> RawSeq<'_, T, U>
where
T: Copy,
U: TryFrom<T::Primitive>,
Expand Down
6 changes: 6 additions & 0 deletions src/packets/caching_sha2_password.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ impl PublicKeyRequest {
}
}

impl Default for PublicKeyRequest {
fn default() -> Self {
Self::new()
}
}

impl<'de> MyDeserialize<'de> for PublicKeyRequest {
const SIZE: Option<usize> = None;
type Ctx = ();
Expand Down
34 changes: 21 additions & 13 deletions src/packets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -678,7 +678,7 @@ pub struct OkPacket<'a> {
session_state_info: Option<RawBytes<'a, LenEnc>>,
}

impl<'a> OkPacket<'a> {
impl OkPacket<'_> {
pub fn into_owned(self) -> OkPacket<'static> {
OkPacket {
affected_rows: self.affected_rows,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 { .. })
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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<Cow<'a, [u8]>>,
Expand Down Expand Up @@ -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<usize> = None;

Expand Down Expand Up @@ -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<u8>) {
self.character_set.serialize(&mut *buf);
if let Some(ref auth_plugin) = self.auth_plugin {
Expand Down Expand Up @@ -2075,6 +2082,7 @@ pub struct HandshakeResponse<'a> {
}

impl<'a> HandshakeResponse<'a> {
#[allow(clippy::too_many_arguments)]
pub fn new(
scramble_buf: Option<impl Into<Cow<'a, [u8]>>>,
server_version: (u16, u16, u16),
Expand Down Expand Up @@ -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()
}

Expand All @@ -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()
}

Expand All @@ -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()
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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<Self, Self::Err> {
Expand Down
2 changes: 1 addition & 1 deletion src/packets/session_state_change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/row/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl ColumnIndex for usize {
}
}

impl<'a> ColumnIndex for &'a str {
impl ColumnIndex for &'_ str {
fn idx(&self, columns: &[Column]) -> Option<usize> {
for (i, c) in columns.iter().enumerate() {
if c.name_ref() == self.as_bytes() {
Expand Down
2 changes: 1 addition & 1 deletion src/value/convert/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 3f4b735

Please sign in to comment.