cargo clippy --fix

This commit is contained in:
Henrik Friedrichsen
2022-08-17 19:41:23 +02:00
parent 0af93f816d
commit f5bf1d527f
5 changed files with 20 additions and 20 deletions

View File

@@ -380,7 +380,7 @@ pub fn parse(input: &str) -> Result<Vec<Command>, CommandParseError> {
"playnext" => Command::PlayNext, "playnext" => Command::PlayNext,
"play" => Command::Play, "play" => Command::Play,
"update" => Command::UpdateLibrary, "update" => Command::UpdateLibrary,
"save" => match args.get(0).cloned() { "save" => match args.first().cloned() {
Some("queue") => Ok(Command::SaveQueue), Some("queue") => Ok(Command::SaveQueue),
Some(arg) => Err(BadEnumArg { Some(arg) => Err(BadEnumArg {
arg: arg.into(), arg: arg.into(),
@@ -390,7 +390,7 @@ pub fn parse(input: &str) -> Result<Vec<Command>, CommandParseError> {
}?, }?,
"delete" => Command::Delete, "delete" => Command::Delete,
"focus" => { "focus" => {
let &target = args.get(0).ok_or(InsufficientArgs { let &target = args.first().ok_or(InsufficientArgs {
cmd: command.into(), cmd: command.into(),
hint: Some("queue|search|library".into()), hint: Some("queue|search|library".into()),
})?; })?;
@@ -443,7 +443,7 @@ pub fn parse(input: &str) -> Result<Vec<Command>, CommandParseError> {
Command::Seek(seek_direction) Command::Seek(seek_direction)
} }
"volup" => { "volup" => {
let amount = match args.get(0) { let amount = match args.first() {
Some(&amount_raw) => { Some(&amount_raw) => {
amount_raw.parse::<u16>().map_err(|err| ArgParseError { amount_raw.parse::<u16>().map_err(|err| ArgParseError {
arg: amount_raw.into(), arg: amount_raw.into(),
@@ -455,7 +455,7 @@ pub fn parse(input: &str) -> Result<Vec<Command>, CommandParseError> {
Command::VolumeUp(amount) Command::VolumeUp(amount)
} }
"voldown" => { "voldown" => {
let amount = match args.get(0) { let amount = match args.first() {
Some(&amount_raw) => { Some(&amount_raw) => {
amount_raw.parse::<u16>().map_err(|err| ArgParseError { amount_raw.parse::<u16>().map_err(|err| ArgParseError {
arg: amount_raw.into(), arg: amount_raw.into(),
@@ -467,7 +467,7 @@ pub fn parse(input: &str) -> Result<Vec<Command>, CommandParseError> {
Command::VolumeDown(amount) Command::VolumeDown(amount)
} }
"repeat" => { "repeat" => {
let mode = match args.get(0).cloned() { let mode = match args.first().cloned() {
Some("list" | "playlist" | "queue") => { Some("list" | "playlist" | "queue") => {
Ok(Some(RepeatSetting::RepeatPlaylist)) Ok(Some(RepeatSetting::RepeatPlaylist))
} }
@@ -492,7 +492,7 @@ pub fn parse(input: &str) -> Result<Vec<Command>, CommandParseError> {
Command::Repeat(mode) Command::Repeat(mode)
} }
"shuffle" => { "shuffle" => {
let switch = match args.get(0).cloned() { let switch = match args.first().cloned() {
Some("on") => Ok(Some(true)), Some("on") => Ok(Some(true)),
Some("off") => Ok(Some(false)), Some("off") => Ok(Some(false)),
Some(arg) => Err(BadEnumArg { Some(arg) => Err(BadEnumArg {
@@ -505,7 +505,7 @@ pub fn parse(input: &str) -> Result<Vec<Command>, CommandParseError> {
} }
#[cfg(feature = "share_clipboard")] #[cfg(feature = "share_clipboard")]
"share" => { "share" => {
let &target_mode_raw = args.get(0).ok_or(InsufficientArgs { let &target_mode_raw = args.first().ok_or(InsufficientArgs {
cmd: command.into(), cmd: command.into(),
hint: Some("selected|current".into()), hint: Some("selected|current".into()),
})?; })?;
@@ -521,7 +521,7 @@ pub fn parse(input: &str) -> Result<Vec<Command>, CommandParseError> {
} }
"back" => Command::Back, "back" => Command::Back,
"open" => { "open" => {
let &target_mode_raw = args.get(0).ok_or(InsufficientArgs { let &target_mode_raw = args.first().ok_or(InsufficientArgs {
cmd: command.into(), cmd: command.into(),
hint: Some("selected|current".into()), hint: Some("selected|current".into()),
})?; })?;
@@ -536,7 +536,7 @@ pub fn parse(input: &str) -> Result<Vec<Command>, CommandParseError> {
Command::Open(target_mode) Command::Open(target_mode)
} }
"goto" => { "goto" => {
let &goto_mode_raw = args.get(0).ok_or(InsufficientArgs { let &goto_mode_raw = args.first().ok_or(InsufficientArgs {
cmd: command.into(), cmd: command.into(),
hint: Some("album|artist".into()), hint: Some("album|artist".into()),
})?; })?;
@@ -551,7 +551,7 @@ pub fn parse(input: &str) -> Result<Vec<Command>, CommandParseError> {
Command::Goto(goto_mode) Command::Goto(goto_mode)
} }
"move" => { "move" => {
let &move_mode_raw = args.get(0).ok_or(InsufficientArgs { let &move_mode_raw = args.first().ok_or(InsufficientArgs {
cmd: command.into(), cmd: command.into(),
hint: Some("a direction".into()), hint: Some("a direction".into()),
})?; })?;
@@ -600,7 +600,7 @@ pub fn parse(input: &str) -> Result<Vec<Command>, CommandParseError> {
Command::Move(move_mode, move_amount) Command::Move(move_mode, move_amount)
} }
"shift" => { "shift" => {
let &shift_dir_raw = args.get(0).ok_or(InsufficientArgs { let &shift_dir_raw = args.first().ok_or(InsufficientArgs {
cmd: command.into(), cmd: command.into(),
hint: Some("up|down".into()), hint: Some("up|down".into()),
})?; })?;
@@ -633,7 +633,7 @@ pub fn parse(input: &str) -> Result<Vec<Command>, CommandParseError> {
"reload" => Command::ReloadConfig, "reload" => Command::ReloadConfig,
"noop" => Command::Noop, "noop" => Command::Noop,
"insert" => { "insert" => {
let insert_source = match args.get(0).cloned() { let insert_source = match args.first().cloned() {
#[cfg(feature = "share_clipboard")] #[cfg(feature = "share_clipboard")]
Some("") | None => Ok(InsertSource::Clipboard), Some("") | None => Ok(InsertSource::Clipboard),
// if clipboard feature is disabled and args is empty // if clipboard feature is disabled and args is empty
@@ -662,7 +662,7 @@ pub fn parse(input: &str) -> Result<Vec<Command>, CommandParseError> {
}? }?
} }
"sort" => { "sort" => {
let &key_raw = args.get(0).ok_or(InsufficientArgs { let &key_raw = args.first().ok_or(InsufficientArgs {
cmd: command.into(), cmd: command.into(),
hint: Some("a sort key".into()), hint: Some("a sort key".into()),
})?; })?;
@@ -705,7 +705,7 @@ pub fn parse(input: &str) -> Result<Vec<Command>, CommandParseError> {
} }
"logout" => Command::Logout, "logout" => Command::Logout,
"similar" => { "similar" => {
let &target_mode_raw = args.get(0).ok_or(InsufficientArgs { let &target_mode_raw = args.first().ok_or(InsufficientArgs {
cmd: command.into(), cmd: command.into(),
hint: Some("selected|current".into()), hint: Some("selected|current".into()),
})?; })?;

View File

@@ -15,7 +15,7 @@ use crate::serialization::{Serializer, CBOR, TOML};
pub const CLIENT_ID: &str = "d420a117a32841c2b3474932e49fb54b"; pub const CLIENT_ID: &str = "d420a117a32841c2b3474932e49fb54b";
pub const CACHE_VERSION: u16 = 1; pub const CACHE_VERSION: u16 = 1;
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)] #[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq)]
pub enum PlaybackState { pub enum PlaybackState {
Playing, Playing,
Paused, Paused,

View File

@@ -16,7 +16,7 @@ use crate::model::playable::Playable;
use crate::spotify::PlayerEvent; use crate::spotify::PlayerEvent;
use crate::spotify::Spotify; use crate::spotify::Spotify;
#[derive(Display, Clone, Copy, PartialEq, Debug, Serialize, Deserialize)] #[derive(Display, Clone, Copy, PartialEq, Eq, Debug, Serialize, Deserialize)]
pub enum RepeatSetting { pub enum RepeatSetting {
#[serde(rename = "off")] #[serde(rename = "off")]
None, None,
@@ -26,7 +26,7 @@ pub enum RepeatSetting {
RepeatTrack, RepeatTrack,
} }
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq, Eq)]
pub enum QueueEvent { pub enum QueueEvent {
PreloadTrackRequest, PreloadTrackRequest,
} }

View File

@@ -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; 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 { pub enum PlayerEvent {
Playing(SystemTime), Playing(SystemTime),
Paused(Duration), 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 { pub enum UriType {
Album, Album,
Artist, Artist,

View File

@@ -445,7 +445,7 @@ impl<I: ListItem + Clone> ViewExt for ListView<I> {
self.search_query = query.to_lowercase(); self.search_query = query.to_lowercase();
self.search_indexes = self.get_indexes_of(query); self.search_indexes = self.get_indexes_of(query);
self.search_selected_index = 0; self.search_selected_index = 0;
match self.search_indexes.get(0) { match self.search_indexes.first() {
Some(&index) => { Some(&index) => {
self.move_focus_to(index); self.move_focus_to(index);
return Ok(CommandResult::Consumed(None)); return Ok(CommandResult::Consumed(None));