Skip to content

Commit 8f9bec2

Browse files
authored
Merge pull request #1284 from yubiuser/fix/clippy
Fix/clippy
2 parents 7d45a94 + 2a8c4bd commit 8f9bec2

13 files changed

Lines changed: 28 additions & 30 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ FROM rust:${rust_version}-${debian_version}
55

66
ARG DEBIAN_FRONTEND=noninteractive
77
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL="sparse"
8+
ENV RUST_BACKTRACE=1
9+
ENV RUSTFLAGS=-Dwarnings
10+
811

912
RUN apt-get update && \
1013
apt-get install -y --no-install-recommends \

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "librespot"
33
version = "0.5.0-dev"
4-
rust-version = "1.61"
4+
rust-version = "1.71"
55
authors = ["Librespot Org"]
66
license = "MIT"
77
description = "An open source client library for Spotify, with support for Spotify Connect"

audio/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "librespot-audio"
33
version = "0.5.0-dev"
4-
rust-version = "1.61"
4+
rust-version = "1.71"
55
authors = ["Paul Lietar <[email protected]>"]
66
description = "The audio fetching logic for librespot"
77
license = "MIT"

connect/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "librespot-connect"
33
version = "0.5.0-dev"
4-
rust-version = "1.61"
4+
rust-version = "1.71"
55
authors = ["Paul Lietar <[email protected]>"]
66
description = "The discovery and Spotify Connect logic for librespot"
77
license = "MIT"

core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "librespot-core"
33
version = "0.5.0-dev"
4-
rust-version = "1.61"
4+
rust-version = "1.71"
55
authors = ["Paul Lietar <[email protected]>"]
66
build = "build.rs"
77
description = "The core functionality provided by librespot"

core/src/config.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ impl Default for SessionConfig {
4343
}
4444
}
4545

46-
#[derive(Clone, Copy, Debug, Hash, PartialOrd, Ord, PartialEq, Eq)]
46+
#[derive(Clone, Copy, Debug, Hash, PartialOrd, Ord, PartialEq, Eq, Default)]
4747
pub enum DeviceType {
4848
Unknown = 0,
4949
Computer = 1,
5050
Tablet = 2,
5151
Smartphone = 3,
52+
#[default]
5253
Speaker = 4,
5354
Tv = 5,
5455
Avr = 6,
@@ -131,9 +132,3 @@ impl fmt::Display for DeviceType {
131132
f.write_str(str)
132133
}
133134
}
134-
135-
impl Default for DeviceType {
136-
fn default() -> DeviceType {
137-
DeviceType::Speaker
138-
}
139-
}

core/src/mercury/types.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ impl From<MercuryError> for Error {
4949
}
5050
}
5151

52-
impl ToString for MercuryMethod {
53-
fn to_string(&self) -> String {
54-
match *self {
52+
impl std::fmt::Display for MercuryMethod {
53+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
54+
let s = match *self {
5555
MercuryMethod::Get => "GET",
5656
MercuryMethod::Sub => "SUB",
5757
MercuryMethod::Unsub => "UNSUB",
5858
MercuryMethod::Send => "SEND",
59-
}
60-
.to_owned()
59+
};
60+
write!(f, "{}", s)
6161
}
6262
}
6363

core/src/session.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ impl Session {
358358
loop {
359359
match reader.read_event_into(&mut buf) {
360360
Ok(Event::Start(ref element)) => {
361-
current_element = std::str::from_utf8(element)?.to_owned()
361+
std::str::from_utf8(element)?.clone_into(&mut current_element)
362362
}
363363
Ok(Event::End(_)) => {
364364
current_element = String::new();
@@ -428,47 +428,47 @@ impl Session {
428428
}
429429

430430
pub fn set_client_id(&self, client_id: &str) {
431-
self.0.data.write().client_id = client_id.to_owned();
431+
client_id.clone_into(&mut self.0.data.write().client_id);
432432
}
433433

434434
pub fn client_name(&self) -> String {
435435
self.0.data.read().client_name.clone()
436436
}
437437

438438
pub fn set_client_name(&self, client_name: &str) {
439-
self.0.data.write().client_name = client_name.to_owned();
439+
client_name.clone_into(&mut self.0.data.write().client_name);
440440
}
441441

442442
pub fn client_brand_name(&self) -> String {
443443
self.0.data.read().client_brand_name.clone()
444444
}
445445

446446
pub fn set_client_brand_name(&self, client_brand_name: &str) {
447-
self.0.data.write().client_brand_name = client_brand_name.to_owned();
447+
client_brand_name.clone_into(&mut self.0.data.write().client_brand_name);
448448
}
449449

450450
pub fn client_model_name(&self) -> String {
451451
self.0.data.read().client_model_name.clone()
452452
}
453453

454454
pub fn set_client_model_name(&self, client_model_name: &str) {
455-
self.0.data.write().client_model_name = client_model_name.to_owned();
455+
client_model_name.clone_into(&mut self.0.data.write().client_model_name);
456456
}
457457

458458
pub fn connection_id(&self) -> String {
459459
self.0.data.read().connection_id.clone()
460460
}
461461

462462
pub fn set_connection_id(&self, connection_id: &str) {
463-
self.0.data.write().connection_id = connection_id.to_owned();
463+
connection_id.clone_into(&mut self.0.data.write().connection_id);
464464
}
465465

466466
pub fn username(&self) -> String {
467467
self.0.data.read().user_data.canonical_username.clone()
468468
}
469469

470470
pub fn set_username(&self, username: &str) {
471-
self.0.data.write().user_data.canonical_username = username.to_owned();
471+
username.clone_into(&mut self.0.data.write().user_data.canonical_username);
472472
}
473473

474474
pub fn country(&self) -> String {

core/src/spclient.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,9 @@ impl SpClient {
239239
let android_data = platform_data.mut_android();
240240
android_data.android_version = os_version;
241241
android_data.api_version = 31;
242-
android_data.device_name = "Pixel".to_owned();
243-
android_data.model_str = "GF5KQ".to_owned();
244-
android_data.vendor = "Google".to_owned();
242+
"Pixel".clone_into(&mut android_data.device_name);
243+
"GF5KQ".clone_into(&mut android_data.model_str);
244+
"Google".clone_into(&mut android_data.vendor);
245245
}
246246
"macos" => {
247247
let macos_data = platform_data.mut_desktop_macos();

discovery/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "librespot-discovery"
33
version = "0.5.0-dev"
4-
rust-version = "1.61"
4+
rust-version = "1.71"
55
authors = ["Paul Lietar <[email protected]>"]
66
description = "The discovery logic for librespot"
77
license = "MIT"

0 commit comments

Comments
 (0)