From 059b9029ded1ac7d08efdef3ec1e841d33b0b5ef Mon Sep 17 00:00:00 2001 From: johannesd3 Date: Wed, 10 Mar 2021 22:39:01 +0100 Subject: [PATCH] Remove redundant field names --- connect/src/discovery.rs | 10 +++++----- connect/src/spirc.rs | 19 ++++++++----------- metadata/src/lib.rs | 27 +++++++++++++-------------- playback/src/player.rs | 23 ++++++++++------------- src/main.rs | 32 ++++++++++++++++---------------- 5 files changed, 52 insertions(+), 59 deletions(-) diff --git a/connect/src/discovery.rs b/connect/src/discovery.rs index e03b1595..7bb36a20 100644 --- a/connect/src/discovery.rs +++ b/connect/src/discovery.rs @@ -51,11 +51,11 @@ impl Discovery { let public_key = util::powm(&DH_GENERATOR, &private_key, &DH_PRIME); let discovery = Discovery(Arc::new(DiscoveryInner { - config: config, - device_id: device_id, - private_key: private_key, - public_key: public_key, - tx: tx, + config, + device_id, + private_key, + public_key, + tx, })); (discovery, rx) diff --git a/connect/src/spirc.rs b/connect/src/spirc.rs index 6869dd8b..f111e541 100644 --- a/connect/src/spirc.rs +++ b/connect/src/spirc.rs @@ -287,27 +287,27 @@ impl Spirc { let player_events = player.get_player_event_channel(); let mut task = SpircTask { - player: player, - mixer: mixer, + player, + mixer, config: task_config, sequence: SeqGenerator::new(1), - ident: ident, + ident, - device: device, + device, state: initial_state(), play_request_id: None, mixer_started: false, play_status: SpircPlayStatus::Stopped, - subscription: subscription, - sender: sender, + subscription, + sender, commands: Some(cmd_rx), player_events: Some(player_events), shutdown: false, - session: session, + session, context_fut: Box::pin(future::pending()), autoplay_fut: Box::pin(future::pending()), @@ -1293,10 +1293,7 @@ impl<'a> CommandSender<'a> { frame.set_typ(cmd); frame.set_device_state(spirc.device.clone()); frame.set_state_update_id(spirc.now_ms()); - CommandSender { - spirc: spirc, - frame: frame, - } + CommandSender { spirc, frame } } fn recipient(mut self, recipient: &'a str) -> CommandSender { diff --git a/metadata/src/lib.rs b/metadata/src/lib.rs index 75c07f83..2c982ec7 100644 --- a/metadata/src/lib.rs +++ b/metadata/src/lib.rs @@ -1,5 +1,4 @@ #![allow(clippy::unused_io_amount)] -#![allow(clippy::redundant_field_names)] #[macro_use] extern crate log; @@ -85,7 +84,7 @@ impl AudioFiles for Track { async fn get_audio_item(session: &Session, id: SpotifyId) -> Result { let item = Self::get(session, id).await?; Ok(AudioItem { - id: id, + id, uri: format!("spotify:track:{}", id.to_base62()), files: item.files, name: item.name, @@ -102,7 +101,7 @@ impl AudioFiles for Episode { let item = Self::get(session, id).await?; Ok(AudioItem { - id: id, + id, uri: format!("spotify:episode:{}", id.to_base62()), files: item.files, name: item.name, @@ -222,8 +221,8 @@ impl Metadata for Track { name: msg.get_name().to_owned(), duration: msg.get_duration(), album: SpotifyId::from_raw(msg.get_album().get_gid()).unwrap(), - artists: artists, - files: files, + artists, + files, alternatives: msg .get_alternative() .iter() @@ -272,9 +271,9 @@ impl Metadata for Album { Album { id: SpotifyId::from_raw(msg.get_gid()).unwrap(), name: msg.get_name().to_owned(), - artists: artists, - tracks: tracks, - covers: covers, + artists, + tracks, + covers, } } } @@ -309,7 +308,7 @@ impl Metadata for Playlist { Playlist { revision: msg.get_revision().to_vec(), name: msg.get_attributes().get_name().to_owned(), - tracks: tracks, + tracks, user: msg.get_owner_username().to_string(), } } @@ -342,7 +341,7 @@ impl Metadata for Artist { Artist { id: SpotifyId::from_raw(msg.get_gid()).unwrap(), name: msg.get_name().to_owned(), - top_tracks: top_tracks, + top_tracks, } } } @@ -388,8 +387,8 @@ impl Metadata for Episode { duration: msg.get_duration().to_owned(), language: msg.get_language().to_owned(), show: SpotifyId::from_raw(msg.get_show().get_gid()).unwrap(), - covers: covers, - files: files, + covers, + files, available: parse_restrictions(msg.get_restriction(), &country, "premium"), explicit: msg.get_explicit().to_owned(), } @@ -427,8 +426,8 @@ impl Metadata for Show { id: SpotifyId::from_raw(msg.get_gid()).unwrap(), name: msg.get_name().to_owned(), publisher: msg.get_publisher().to_owned(), - episodes: episodes, - covers: covers, + episodes, + covers, } } } diff --git a/playback/src/player.rs b/playback/src/player.rs index 6c9e516d..0d2380e7 100644 --- a/playback/src/player.rs +++ b/playback/src/player.rs @@ -204,10 +204,10 @@ impl NormalisationData { let album_peak = file.read_f32::()?; let r = NormalisationData { - track_gain_db: track_gain_db, - track_peak: track_peak, - album_gain_db: album_gain_db, - album_peak: album_peak, + track_gain_db, + track_peak, + album_gain_db, + album_peak, }; Ok(r) @@ -1164,8 +1164,8 @@ impl PlayerInternal { }); self.state = PlayerState::Playing { - track_id: track_id, - play_request_id: play_request_id, + track_id, + play_request_id, decoder: loaded_track.decoder, normalisation_factor: loaded_track.normalisation_factor, stream_loader_controller: loaded_track.stream_loader_controller, @@ -1181,8 +1181,8 @@ impl PlayerInternal { self.ensure_sink_stopped(false); self.state = PlayerState::Paused { - track_id: track_id, - play_request_id: play_request_id, + track_id, + play_request_id, decoder: loaded_track.decoder, normalisation_factor: loaded_track.normalisation_factor, stream_loader_controller: loaded_track.stream_loader_controller, @@ -1229,7 +1229,7 @@ impl PlayerInternal { track_id: old_track_id, .. } => self.send_event(PlayerEvent::Changed { - old_track_id: old_track_id, + old_track_id, new_track_id: track_id, }), PlayerState::Stopped => self.send_event(PlayerEvent::Started { @@ -1726,10 +1726,7 @@ struct Subfile { impl Subfile { pub fn new(mut stream: T, offset: u64) -> Subfile { stream.seek(SeekFrom::Start(offset)).unwrap(); - Subfile { - stream: stream, - offset: offset, - } + Subfile { stream, offset } } } diff --git a/src/main.rs b/src/main.rs index ff9e564c..5b445b2c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -353,7 +353,7 @@ fn setup(args: &[String]) -> Setup { SessionConfig { user_agent: version::version_string(), - device_id: device_id, + device_id, proxy: matches.opt_str("proxy").or_else(|| std::env::var("http_proxy").ok()).map( |s| { match Url::parse(&s) { @@ -393,7 +393,7 @@ fn setup(args: &[String]) -> Setup { }) .unwrap_or_default(); PlayerConfig { - bitrate: bitrate, + bitrate, gapless: !matches.opt_present("disable-gapless"), normalisation: matches.opt_present("enable-volume-normalisation"), normalisation_type: gain_type, @@ -419,10 +419,10 @@ fn setup(args: &[String]) -> Setup { .unwrap_or_default(); ConnectConfig { - name: name, - device_type: device_type, + name, + device_type, volume: initial_volume, - volume_ctrl: volume_ctrl, + volume_ctrl, autoplay: matches.opt_present("autoplay"), } }; @@ -430,17 +430,17 @@ fn setup(args: &[String]) -> Setup { let enable_discovery = !matches.opt_present("disable-discovery"); Setup { - backend: backend, - cache: cache, - session_config: session_config, - player_config: player_config, - connect_config: connect_config, - credentials: credentials, - device: device, - enable_discovery: enable_discovery, - zeroconf_port: zeroconf_port, - mixer: mixer, - mixer_config: mixer_config, + backend, + cache, + session_config, + player_config, + connect_config, + credentials, + device, + enable_discovery, + zeroconf_port, + mixer, + mixer_config, player_event_program: matches.opt_str("onevent"), emit_sink_events: matches.opt_present("emit-sink-events"), }