1
0
Fork 0
mirror of https://github.com/librespot-org/librespot.git synced 2025-10-03 01:39:28 +02:00

Chore: fix clippy warnings for stable (1.87) and nightly (1.89) (#1504)

* chore: stable - fix clippy warnings

* chore: nightly - fix clippy warnings
This commit is contained in:
Felix Prillwitz 2025-06-09 12:13:17 +02:00 committed by GitHub
parent 8b729540f4
commit 3686718ea2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 13 additions and 19 deletions

View file

@ -57,7 +57,7 @@ impl std::fmt::Display for MercuryMethod {
MercuryMethod::Unsub => "UNSUB",
MercuryMethod::Send => "SEND",
};
write!(f, "{}", s)
write!(f, "{s}")
}
}

View file

@ -22,7 +22,7 @@ pub async fn proxy_connect<T: AsyncRead + AsyncWrite + Unpin>(
loop {
let bytes_read = proxy_connection.read(&mut buffer[offset..]).await?;
if bytes_read == 0 {
return Err(io::Error::new(io::ErrorKind::Other, "Early EOF from proxy"));
return Err(io::Error::other("Early EOF from proxy"));
}
offset += bytes_read;
@ -31,7 +31,7 @@ pub async fn proxy_connect<T: AsyncRead + AsyncWrite + Unpin>(
let status = response
.parse(&buffer[..offset])
.map_err(|err| io::Error::new(io::ErrorKind::Other, err))?;
.map_err(io::Error::other)?;
if status.is_complete() {
return match response.code {
@ -39,12 +39,9 @@ pub async fn proxy_connect<T: AsyncRead + AsyncWrite + Unpin>(
Some(code) => {
let reason = response.reason.unwrap_or("no reason");
let msg = format!("Proxy responded with {code}: {reason}");
Err(io::Error::new(io::ErrorKind::Other, msg))
Err(io::Error::other(msg))
}
None => Err(io::Error::new(
io::ErrorKind::Other,
"Malformed response from proxy",
)),
None => Err(io::Error::other("Malformed response from proxy")),
};
}

View file

@ -96,12 +96,10 @@ pub fn find(name: Option<&str>) -> Result<DnsSdServiceBuilder, Error> {
match BACKENDS.iter().find(|(id, _)| name == id) {
Some((_id, Some(launch_svc))) => Ok(*launch_svc),
Some((_id, None)) => Err(Error::unavailable(format!(
"librespot built without '{}' support",
name
"librespot built without '{name}' support"
))),
None => Err(Error::not_found(format!(
"unknown zeroconf backend '{}'",
name
"unknown zeroconf backend '{name}'"
))),
}
} else {
@ -286,14 +284,14 @@ async fn avahi_task(
//
// EntryGroup has been withdrawn at this point already!
log::error!("zeroconf collision for name '{}'", &name);
return Err(zbus::Error::Failure(format!("zeroconf collision for name: {}", name)).into());
return Err(zbus::Error::Failure(format!("zeroconf collision for name: {name}")).into());
}
EntryGroupState::Failure => {
// TODO: Back off/treat as fatal?
// EntryGroup has been withdrawn at this point already!
// There seems to be no code in Avahi that actually sets this state.
log::error!("zeroconf failure: {}", error);
return Err(zbus::Error::Failure(format!("zeroconf failure: {}", error)).into());
return Err(zbus::Error::Failure(format!("zeroconf failure: {error}")).into());
}
}
}

View file

@ -237,7 +237,7 @@ impl OAuthClient {
if self.should_open_url {
open::that_in_background(auth_url.as_str());
}
println!("Browse to: {}", auth_url);
println!("Browse to: {auth_url}");
pkce_verifier
}
@ -456,7 +456,7 @@ pub fn get_access_token(
.set_pkce_challenge(pkce_challenge)
.url();
println!("Browse to: {}", auth_url);
println!("Browse to: {auth_url}");
let code = match get_socket_address(redirect_uri) {
Some(addr) => get_authcode_listener(addr, String::from("Go back to your terminal :)")),

View file

@ -158,6 +158,6 @@ impl CubicMapping {
fn min_norm(db_range: f64) -> f64 {
// Note that this 60.0 is unrelated to DEFAULT_DB_RANGE.
// Instead, it's the cubic voltage to dB ratio.
f64::powf(10.0, -1.0 * db_range / 60.0)
f64::powf(10.0, -db_range / 60.0)
}
}

View file

@ -1227,8 +1227,7 @@ fn get_setup() -> Setup {
Some("librespot compiled without zeroconf backend".to_owned())
} else if opt_present(DISABLE_DISCOVERY) {
Some(format!(
"the `--{}` / `-{}` flag set",
DISABLE_DISCOVERY, DISABLE_DISCOVERY_SHORT,
"the `--{DISABLE_DISCOVERY}` / `-{DISABLE_DISCOVERY_SHORT}` flag set",
))
} else {
None