Skip to content

Commit

Permalink
cargo clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
hrkfdn committed Oct 10, 2020
1 parent f40b36c commit f3c6611
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ fn main() {
let mut main = s.find_name::<ui::layout::Layout>("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::<UserData>().cloned() {
Expand Down
9 changes: 3 additions & 6 deletions src/spotify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down Expand Up @@ -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<Duration>) {
Expand Down
14 changes: 7 additions & 7 deletions src/ui/listview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl<I: ListItem> ListView<I> {
self.selected
}

pub fn get_indexes_of(&self, query: &String) -> Vec<usize> {
pub fn get_indexes_of(&self, query: &str) -> Vec<usize> {
let content = self.content.read().unwrap();
content
.iter()
Expand Down Expand Up @@ -554,22 +554,22 @@ impl<I: ListItem + Clone> ViewExt for ListView<I> {
let target: Option<Box<dyn ListItem>> = 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,
};

Expand Down

0 comments on commit f3c6611

Please sign in to comment.