From 5dbb288a496d53a299effa2026f5258af7b1f176 Mon Sep 17 00:00:00 2001 From: ThetaDev Date: Thu, 2 May 2024 18:46:21 +0200 Subject: [PATCH 1/2] chore: introduce MSRV --- Cargo.toml | 2 ++ cli/Cargo.toml | 1 + codegen/Cargo.toml | 1 + downloader/Cargo.toml | 1 + 4 files changed, 5 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 2485421..8c92bcf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,7 @@ name = "rustypipe" version = "0.1.3" edition.workspace = true +rust-version.workspace = true authors.workspace = true license.workspace = true repository.workspace = true @@ -16,6 +17,7 @@ members = [".", "codegen", "downloader", "cli"] [workspace.package] edition = "2021" +rust-version = "1.67.1" authors = ["ThetaDev "] license = "GPL-3.0" repository = "https://code.thetadev.de/ThetaDev/rustypipe" diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 53556b8..802f588 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -2,6 +2,7 @@ name = "rustypipe-cli" version = "0.1.0" edition.workspace = true +rust-version.workspace = true authors.workspace = true license.workspace = true repository.workspace = true diff --git a/codegen/Cargo.toml b/codegen/Cargo.toml index c47f1df..d38e104 100644 --- a/codegen/Cargo.toml +++ b/codegen/Cargo.toml @@ -2,6 +2,7 @@ name = "rustypipe-codegen" version = "0.1.0" edition.workspace = true +rust-version.workspace = true authors.workspace = true license.workspace = true repository.workspace = true diff --git a/downloader/Cargo.toml b/downloader/Cargo.toml index 1479524..c068ca2 100644 --- a/downloader/Cargo.toml +++ b/downloader/Cargo.toml @@ -2,6 +2,7 @@ name = "rustypipe-downloader" version = "0.1.0" edition.workspace = true +rust-version.workspace = true authors.workspace = true license.workspace = true repository.workspace = true From 45b9f2a627b4e7075ba0b1c5f16efcc19aef7922 Mon Sep 17 00:00:00 2001 From: ThetaDev Date: Thu, 2 May 2024 19:39:48 +0200 Subject: [PATCH 2/2] chore: fix clippy lints --- Cargo.toml | 3 +-- cli/Cargo.toml | 2 +- codegen/Cargo.toml | 2 +- codegen/src/model.rs | 8 ++++---- downloader/Cargo.toml | 2 +- src/client/player.rs | 2 +- src/client/response/music_item.rs | 4 ++-- src/model/mod.rs | 6 +++--- src/serializer/text.rs | 9 ++++++--- src/util/mod.rs | 1 + 10 files changed, 21 insertions(+), 18 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8c92bcf..4203e8e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "rustypipe" version = "0.1.3" +rust-version = "1.67.1" edition.workspace = true -rust-version.workspace = true authors.workspace = true license.workspace = true repository.workspace = true @@ -17,7 +17,6 @@ members = [".", "codegen", "downloader", "cli"] [workspace.package] edition = "2021" -rust-version = "1.67.1" authors = ["ThetaDev "] license = "GPL-3.0" repository = "https://code.thetadev.de/ThetaDev/rustypipe" diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 802f588..3ba9b45 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "rustypipe-cli" version = "0.1.0" +rust-version = "1.74.0" edition.workspace = true -rust-version.workspace = true authors.workspace = true license.workspace = true repository.workspace = true diff --git a/codegen/Cargo.toml b/codegen/Cargo.toml index d38e104..7a0e5d1 100644 --- a/codegen/Cargo.toml +++ b/codegen/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "rustypipe-codegen" version = "0.1.0" +rust-version = "1.74.0" edition.workspace = true -rust-version.workspace = true authors.workspace = true license.workspace = true repository.workspace = true diff --git a/codegen/src/model.rs b/codegen/src/model.rs index f7599cf..0f445a6 100644 --- a/codegen/src/model.rs +++ b/codegen/src/model.rs @@ -67,12 +67,12 @@ pub struct TimeAgo { pub unit: TimeUnit, } -impl ToString for TimeAgo { - fn to_string(&self) -> String { +impl std::fmt::Display for TimeAgo { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { if self.n > 1 { - format!("{}{}", self.n, self.unit.as_str()) + write!(f, "{}{}", self.n, self.unit.as_str()) } else { - self.unit.as_str().to_owned() + f.write_str(self.unit.as_str()) } } } diff --git a/downloader/Cargo.toml b/downloader/Cargo.toml index c068ca2..7f0190d 100644 --- a/downloader/Cargo.toml +++ b/downloader/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "rustypipe-downloader" version = "0.1.0" +rust-version = "1.67.1" edition.workspace = true -rust-version.workspace = true authors.workspace = true license.workspace = true repository.workspace = true diff --git a/src/client/player.rs b/src/client/player.rs index ba1bee8..d95043e 100644 --- a/src/client/player.rs +++ b/src/client/player.rs @@ -429,7 +429,7 @@ fn deobf_nsig( } else { let nsig = deobf.deobfuscate_nsig(n)?; last_nsig[0] = n.to_string(); - last_nsig[1] = nsig.clone(); + last_nsig[1].clone_from(&nsig); nsig }; diff --git a/src/client/response/music_item.rs b/src/client/response/music_item.rs index 4aa0b50..dc29688 100644 --- a/src/client/response/music_item.rs +++ b/src/client/response/music_item.rs @@ -721,7 +721,7 @@ impl MusicListMapper { .unwrap_or_default() })) { - artists = fb_artists.clone(); + artists.clone_from(fb_artists); } } @@ -787,7 +787,7 @@ impl MusicListMapper { // fall back to menu data if let Some(a1) = artists.first_mut() { if a1.id.is_none() { - a1.id = artist_id.clone(); + a1.id.clone_from(&artist_id); } } diff --git a/src/model/mod.rs b/src/model/mod.rs index 8b695b4..1a6029d 100644 --- a/src/model/mod.rs +++ b/src/model/mod.rs @@ -68,9 +68,9 @@ pub enum UrlTarget { }, } -impl ToString for UrlTarget { - fn to_string(&self) -> String { - self.to_url() +impl std::fmt::Display for UrlTarget { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str(&self.to_url()) } } diff --git a/src/serializer/text.rs b/src/serializer/text.rs index b708625..f146e7f 100644 --- a/src/serializer/text.rs +++ b/src/serializer/text.rs @@ -658,9 +658,12 @@ impl TextComponents { } } -impl ToString for TextComponents { - fn to_string(&self) -> String { - self.0.iter().map(TextComponent::as_str).collect::() +impl std::fmt::Display for TextComponents { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + for t in &self.0 { + f.write_str(t.as_str())?; + } + Ok(()) } } diff --git a/src/util/mod.rs b/src/util/mod.rs index d11c66c..75dcb00 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -284,6 +284,7 @@ pub fn div_ceil(a: u32, b: u32) -> u32 { } } +#[allow(dead_code)] pub trait TryRemove { /// Removes and returns the element at position `index` within the vector, /// shifting all elements after it to the left.