Skip to content

Commit 2a3e248

Browse files
committed
Fix clippy lints
1 parent 3d29876 commit 2a3e248

7 files changed

Lines changed: 31 additions & 41 deletions

File tree

core/build.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,14 @@ fn main() {
88
flags.toggle(ConstantsFlags::REBUILD_ON_HEAD_CHANGE);
99
generate_cargo_keys(ConstantsFlags::all()).expect("Unable to generate the cargo keys!");
1010

11-
let build_id: String;
12-
match env::var("SOURCE_DATE_EPOCH") {
13-
Ok(val) => build_id = val,
14-
Err(_) => {
15-
build_id = rand::thread_rng()
16-
.sample_iter(Alphanumeric)
17-
.take(8)
18-
.map(char::from)
19-
.collect()
20-
}
21-
}
11+
let build_id = match env::var("SOURCE_DATE_EPOCH") {
12+
Ok(val) => val,
13+
Err(_) => rand::thread_rng()
14+
.sample_iter(Alphanumeric)
15+
.take(8)
16+
.map(char::from)
17+
.collect(),
18+
};
2219

2320
println!("cargo:rustc-env=LIBRESPOT_BUILD_ID={}", build_id);
2421
}

discovery/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ edition = "2018"
1010
[dependencies]
1111
aes-ctr = "0.6"
1212
base64 = "0.13"
13-
cfg-if = "1.0"
1413
form_urlencoded = "1.0"
1514
futures-core = "0.3"
1615
hmac = "0.11"

discovery/src/lib.rs

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use std::io;
1616
use std::pin::Pin;
1717
use std::task::{Context, Poll};
1818

19-
use cfg_if::cfg_if;
2019
use futures_core::Stream;
2120
use librespot_core as core;
2221
use thiserror::Error;
@@ -100,29 +99,24 @@ impl Builder {
10099
let name = self.server_config.name.clone().into_owned();
101100
let server = DiscoveryServer::new(self.server_config, &mut port)?;
102101

103-
let svc;
104-
105-
cfg_if! {
106-
if #[cfg(feature = "with-dns-sd")] {
107-
svc = dns_sd::DNSService::register(
108-
Some(name.as_ref()),
109-
"_spotify-connect._tcp",
110-
None,
111-
None,
112-
port,
113-
&["VERSION=1.0", "CPath=/"],
114-
).map_err(|e| Error::DnsSdError(io::Error::new(io::ErrorKind::Unsupported, e)))?;
115-
116-
} else {
117-
let responder = libmdns::Responder::spawn(&tokio::runtime::Handle::current())?;
118-
svc = responder.register(
119-
"_spotify-connect._tcp".to_owned(),
120-
name,
121-
port,
122-
&["VERSION=1.0", "CPath=/"],
123-
)
124-
}
125-
};
102+
#[cfg(feature = "with-dns-sd")]
103+
let svc = dns_sd::DNSService::register(
104+
Some(name.as_ref()),
105+
"_spotify-connect._tcp",
106+
None,
107+
None,
108+
port,
109+
&["VERSION=1.0", "CPath=/"],
110+
)
111+
.map_err(|e| Error::DnsSdError(io::Error::new(io::ErrorKind::Unsupported, e)))?;
112+
113+
#[cfg(not(feature = "with-dns-sd"))]
114+
let svc = libmdns::Responder::spawn(&tokio::runtime::Handle::current())?.register(
115+
"_spotify-connect._tcp".to_owned(),
116+
name,
117+
port,
118+
&["VERSION=1.0", "CPath=/"],
119+
);
126120

127121
Ok(Discovery { server, _svc: svc })
128122
}

playback/src/mixer/alsamixer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ impl Mixer for AlsaMixer {
191191
mapped_volume = LogMapping::linear_to_mapped(mapped_volume, self.db_range);
192192
}
193193

194-
self.config.volume_ctrl.from_mapped(mapped_volume)
194+
self.config.volume_ctrl.to_unmapped(mapped_volume)
195195
}
196196

197197
fn set_volume(&self, volume: u16) {

playback/src/mixer/mappings.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::player::db_to_ratio;
33

44
pub trait MappedCtrl {
55
fn to_mapped(&self, volume: u16) -> f64;
6-
fn from_mapped(&self, mapped_volume: f64) -> u16;
6+
fn to_unmapped(&self, mapped_volume: f64) -> u16;
77

88
fn db_range(&self) -> f64;
99
fn set_db_range(&mut self, new_db_range: f64);
@@ -49,7 +49,7 @@ impl MappedCtrl for VolumeCtrl {
4949
mapped_volume
5050
}
5151

52-
fn from_mapped(&self, mapped_volume: f64) -> u16 {
52+
fn to_unmapped(&self, mapped_volume: f64) -> u16 {
5353
// More than just an optimization, this ensures that zero mapped volume
5454
// is unmapped to non-negative real numbers (otherwise the log and cubic
5555
// equations would respectively return -inf and -1/9.)

playback/src/mixer/softmixer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl Mixer for SoftMixer {
2626

2727
fn volume(&self) -> u16 {
2828
let mapped_volume = f64::from_bits(self.volume.load(Ordering::Relaxed));
29-
self.volume_ctrl.from_mapped(mapped_volume)
29+
self.volume_ctrl.to_unmapped(mapped_volume)
3030
}
3131

3232
fn set_volume(&self, volume: u16) {

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ fn get_setup() -> Setup {
586586

587587
let stripped_env_key = |k: &str| {
588588
k.trim_start_matches("LIBRESPOT_")
589-
.replace("_", "-")
589+
.replace('_', "-")
590590
.to_lowercase()
591591
};
592592

0 commit comments

Comments
 (0)