diff --git a/src/main.rs b/src/main.rs index ad31e435..90da4862 100644 --- a/src/main.rs +++ b/src/main.rs @@ -313,7 +313,7 @@ fn main() { let mut main = s.find_name::("main").unwrap(); main.clear_cmdline(); } - if cmd.starts_with("/") { + if cmd.starts_with('/') { let query = &cmd[1..]; let command = Command::Jump(JumpMode::Query(query.to_string())); if let Some(data) = s.user_data::().cloned() { diff --git a/src/spotify.rs b/src/spotify.rs index d6675239..c2302401 100644 --- a/src/spotify.rs +++ b/src/spotify.rs @@ -266,10 +266,7 @@ impl Spotify { _ => queue::RepeatSetting::None, }; let shuffle = match &cfg.saved_state { - Some(state) => match &state.shuffle { - Some(true) => true, - _ => false, - }, + Some(state) => matches!(&state.shuffle, Some(true)), None => false, }; @@ -454,11 +451,11 @@ impl Spotify { } pub fn get_current_progress(&self) -> Duration { - self.get_elapsed().unwrap_or(Duration::from_secs(0)) + self.get_elapsed().unwrap_or_else(|| Duration::from_secs(0)) + self .get_since() .map(|t| t.elapsed().unwrap()) - .unwrap_or(Duration::from_secs(0)) + .unwrap_or_else(|| Duration::from_secs(0)) } fn set_elapsed(&self, new_elapsed: Option) { diff --git a/src/ui/listview.rs b/src/ui/listview.rs index 26c4d48e..5f799878 100644 --- a/src/ui/listview.rs +++ b/src/ui/listview.rs @@ -142,7 +142,7 @@ impl ListView { self.selected } - pub fn get_indexes_of(&self, query: &String) -> Vec { + pub fn get_indexes_of(&self, query: &str) -> Vec { let content = self.content.read().unwrap(); content .iter() @@ -554,22 +554,22 @@ impl ViewExt for ListView { let target: Option> = match &captures[2] { "track" => spotify .track(&url) - .and_then(|track| Some(Track::from(&track).as_listitem())), + .map(|track| Track::from(&track).as_listitem()), "album" => spotify .album(&url) - .and_then(|album| Some(Album::from(&album).as_listitem())), + .map(|album| Album::from(&album).as_listitem()), "playlist" => spotify .playlist(&url) - .and_then(|playlist| Some(Playlist::from(&playlist).as_listitem())), + .map(|playlist| Playlist::from(&playlist).as_listitem()), "artist" => spotify .artist(&url) - .and_then(|artist| Some(Artist::from(&artist).as_listitem())), + .map(|artist| Artist::from(&artist).as_listitem()), "episode" => spotify .episode(&url) - .and_then(|episode| Some(Episode::from(&episode).as_listitem())), + .map(|episode| Episode::from(&episode).as_listitem()), "show" => spotify .get_show(&url) - .and_then(|show| Some(Show::from(&show).as_listitem())), + .map(|show| Show::from(&show).as_listitem()), _ => None, };