From f5bf1d527fdda331f0094ce9cb41b55f199834b1 Mon Sep 17 00:00:00 2001 From: Henrik Friedrichsen Date: Wed, 17 Aug 2022 19:41:23 +0200 Subject: [PATCH] `cargo clippy --fix` --- src/command.rs | 28 ++++++++++++++-------------- src/config.rs | 2 +- src/queue.rs | 4 ++-- src/spotify.rs | 4 ++-- src/ui/listview.rs | 2 +- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/command.rs b/src/command.rs index 4dc488d..d94ef80 100644 --- a/src/command.rs +++ b/src/command.rs @@ -380,7 +380,7 @@ pub fn parse(input: &str) -> Result, CommandParseError> { "playnext" => Command::PlayNext, "play" => Command::Play, "update" => Command::UpdateLibrary, - "save" => match args.get(0).cloned() { + "save" => match args.first().cloned() { Some("queue") => Ok(Command::SaveQueue), Some(arg) => Err(BadEnumArg { arg: arg.into(), @@ -390,7 +390,7 @@ pub fn parse(input: &str) -> Result, CommandParseError> { }?, "delete" => Command::Delete, "focus" => { - let &target = args.get(0).ok_or(InsufficientArgs { + let &target = args.first().ok_or(InsufficientArgs { cmd: command.into(), hint: Some("queue|search|library".into()), })?; @@ -443,7 +443,7 @@ pub fn parse(input: &str) -> Result, CommandParseError> { Command::Seek(seek_direction) } "volup" => { - let amount = match args.get(0) { + let amount = match args.first() { Some(&amount_raw) => { amount_raw.parse::().map_err(|err| ArgParseError { arg: amount_raw.into(), @@ -455,7 +455,7 @@ pub fn parse(input: &str) -> Result, CommandParseError> { Command::VolumeUp(amount) } "voldown" => { - let amount = match args.get(0) { + let amount = match args.first() { Some(&amount_raw) => { amount_raw.parse::().map_err(|err| ArgParseError { arg: amount_raw.into(), @@ -467,7 +467,7 @@ pub fn parse(input: &str) -> Result, CommandParseError> { Command::VolumeDown(amount) } "repeat" => { - let mode = match args.get(0).cloned() { + let mode = match args.first().cloned() { Some("list" | "playlist" | "queue") => { Ok(Some(RepeatSetting::RepeatPlaylist)) } @@ -492,7 +492,7 @@ pub fn parse(input: &str) -> Result, CommandParseError> { Command::Repeat(mode) } "shuffle" => { - let switch = match args.get(0).cloned() { + let switch = match args.first().cloned() { Some("on") => Ok(Some(true)), Some("off") => Ok(Some(false)), Some(arg) => Err(BadEnumArg { @@ -505,7 +505,7 @@ pub fn parse(input: &str) -> Result, CommandParseError> { } #[cfg(feature = "share_clipboard")] "share" => { - let &target_mode_raw = args.get(0).ok_or(InsufficientArgs { + let &target_mode_raw = args.first().ok_or(InsufficientArgs { cmd: command.into(), hint: Some("selected|current".into()), })?; @@ -521,7 +521,7 @@ pub fn parse(input: &str) -> Result, CommandParseError> { } "back" => Command::Back, "open" => { - let &target_mode_raw = args.get(0).ok_or(InsufficientArgs { + let &target_mode_raw = args.first().ok_or(InsufficientArgs { cmd: command.into(), hint: Some("selected|current".into()), })?; @@ -536,7 +536,7 @@ pub fn parse(input: &str) -> Result, CommandParseError> { Command::Open(target_mode) } "goto" => { - let &goto_mode_raw = args.get(0).ok_or(InsufficientArgs { + let &goto_mode_raw = args.first().ok_or(InsufficientArgs { cmd: command.into(), hint: Some("album|artist".into()), })?; @@ -551,7 +551,7 @@ pub fn parse(input: &str) -> Result, CommandParseError> { Command::Goto(goto_mode) } "move" => { - let &move_mode_raw = args.get(0).ok_or(InsufficientArgs { + let &move_mode_raw = args.first().ok_or(InsufficientArgs { cmd: command.into(), hint: Some("a direction".into()), })?; @@ -600,7 +600,7 @@ pub fn parse(input: &str) -> Result, CommandParseError> { Command::Move(move_mode, move_amount) } "shift" => { - let &shift_dir_raw = args.get(0).ok_or(InsufficientArgs { + let &shift_dir_raw = args.first().ok_or(InsufficientArgs { cmd: command.into(), hint: Some("up|down".into()), })?; @@ -633,7 +633,7 @@ pub fn parse(input: &str) -> Result, CommandParseError> { "reload" => Command::ReloadConfig, "noop" => Command::Noop, "insert" => { - let insert_source = match args.get(0).cloned() { + let insert_source = match args.first().cloned() { #[cfg(feature = "share_clipboard")] Some("") | None => Ok(InsertSource::Clipboard), // if clipboard feature is disabled and args is empty @@ -662,7 +662,7 @@ pub fn parse(input: &str) -> Result, CommandParseError> { }? } "sort" => { - let &key_raw = args.get(0).ok_or(InsufficientArgs { + let &key_raw = args.first().ok_or(InsufficientArgs { cmd: command.into(), hint: Some("a sort key".into()), })?; @@ -705,7 +705,7 @@ pub fn parse(input: &str) -> Result, CommandParseError> { } "logout" => Command::Logout, "similar" => { - let &target_mode_raw = args.get(0).ok_or(InsufficientArgs { + let &target_mode_raw = args.first().ok_or(InsufficientArgs { cmd: command.into(), hint: Some("selected|current".into()), })?; diff --git a/src/config.rs b/src/config.rs index a7ed946..eeb7fe2 100644 --- a/src/config.rs +++ b/src/config.rs @@ -15,7 +15,7 @@ use crate::serialization::{Serializer, CBOR, TOML}; pub const CLIENT_ID: &str = "d420a117a32841c2b3474932e49fb54b"; pub const CACHE_VERSION: u16 = 1; -#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)] +#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq)] pub enum PlaybackState { Playing, Paused, diff --git a/src/queue.rs b/src/queue.rs index b3ed7a7..08a7898 100644 --- a/src/queue.rs +++ b/src/queue.rs @@ -16,7 +16,7 @@ use crate::model::playable::Playable; use crate::spotify::PlayerEvent; use crate::spotify::Spotify; -#[derive(Display, Clone, Copy, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Display, Clone, Copy, PartialEq, Eq, Debug, Serialize, Deserialize)] pub enum RepeatSetting { #[serde(rename = "off")] None, @@ -26,7 +26,7 @@ pub enum RepeatSetting { RepeatTrack, } -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum QueueEvent { PreloadTrackRequest, } diff --git a/src/spotify.rs b/src/spotify.rs index 7b9ef85..36f61f2 100644 --- a/src/spotify.rs +++ b/src/spotify.rs @@ -31,7 +31,7 @@ use crate::spotify_worker::{Worker, WorkerCommand}; pub const VOLUME_PERCENT: u16 = ((u16::max_value() as f64) * 1.0 / 100.0) as u16; -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum PlayerEvent { Playing(SystemTime), Paused(Duration), @@ -384,7 +384,7 @@ impl Spotify { } } -#[derive(Copy, Clone, Serialize, Deserialize, Debug, PartialEq)] +#[derive(Copy, Clone, Serialize, Deserialize, Debug, PartialEq, Eq)] pub enum UriType { Album, Artist, diff --git a/src/ui/listview.rs b/src/ui/listview.rs index 8e0974c..5a8b2a4 100644 --- a/src/ui/listview.rs +++ b/src/ui/listview.rs @@ -445,7 +445,7 @@ impl ViewExt for ListView { self.search_query = query.to_lowercase(); self.search_indexes = self.get_indexes_of(query); self.search_selected_index = 0; - match self.search_indexes.get(0) { + match self.search_indexes.first() { Some(&index) => { self.move_focus_to(index); return Ok(CommandResult::Consumed(None));