From 93816af654f0d565c81dccb542fe938568fe6bd1 Mon Sep 17 00:00:00 2001 From: Henrik Friedrichsen Date: Wed, 28 Dec 2022 14:34:17 +0100 Subject: [PATCH] Linter fixes --- src/mpris.rs | 2 +- src/spotify_api.rs | 4 +--- src/ui/pagination.rs | 4 ++-- src/ui/queue.rs | 4 ++-- src/utils.rs | 2 +- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/mpris.rs b/src/mpris.rs index 9583bbc..02a493f 100644 --- a/src/mpris.rs +++ b/src/mpris.rs @@ -156,7 +156,7 @@ fn get_metadata(playable: Option, spotify: Spotify, library: Arc 1.0, false => 0.0, }) - .unwrap_or(0.0) as f64, + .unwrap_or(0.0), )), ); diff --git a/src/spotify_api.rs b/src/spotify_api.rs index f951734..78c64ad 100644 --- a/src/spotify_api.rs +++ b/src/spotify_api.rs @@ -118,9 +118,7 @@ impl WebApi { .header("Retry-After") .and_then(|v| v.parse::().ok()); debug!("rate limit hit. waiting {:?} seconds", waiting_duration); - thread::sleep( - Duration::from_secs(waiting_duration.unwrap_or(0) as u64), - ); + thread::sleep(Duration::from_secs(waiting_duration.unwrap_or(0))); cb(&self.api).ok() } 401 => { diff --git a/src/ui/pagination.rs b/src/ui/pagination.rs index ce05bbb..d294613 100644 --- a/src/ui/pagination.rs +++ b/src/ui/pagination.rs @@ -50,7 +50,7 @@ impl ApiResult { } pub fn at_end(&self) -> bool { - (self.offset() + self.limit as u32) >= self.total + (self.offset() + self.limit) >= self.total } pub fn apply_pagination(self, pagination: &Pagination) { @@ -66,7 +66,7 @@ impl ApiResult { } pub fn next(&self) -> Option> { - let offset = self.offset() + self.limit as u32; + let offset = self.offset() + self.limit; debug!("fetching next page at offset {}", offset); if !self.at_end() { if let Some(next_page) = (self.fetch_page)(offset) { diff --git a/src/ui/queue.rs b/src/ui/queue.rs index 4178262..d0342a1 100644 --- a/src/ui/queue.rs +++ b/src/ui/queue.rs @@ -151,13 +151,13 @@ impl ViewExt for QueueView { ShiftMode::Up if selected > 0 => { self.queue .shift(selected, (selected as i32).saturating_sub(amount) as usize); - self.list.move_focus(-(amount as i32)); + self.list.move_focus(-amount); return Ok(CommandResult::Consumed(None)); } ShiftMode::Down if selected < len.saturating_sub(1) => { self.queue .shift(selected, min(selected + amount as usize, len - 1)); - self.list.move_focus(amount as i32); + self.list.move_focus(amount); return Ok(CommandResult::Consumed(None)); } _ => {} diff --git a/src/utils.rs b/src/utils.rs index 7c8d7cf..e3fd1ba 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -31,7 +31,7 @@ pub fn cache_path_for_url(url: String) -> std::path::PathBuf { } pub fn download(url: String, path: std::path::PathBuf) -> Result<(), std::io::Error> { - let mut resp = reqwest::blocking::get(&url) + let mut resp = reqwest::blocking::get(url) .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?; std::fs::create_dir_all(path.parent().unwrap())?;