Linter fixes

This commit is contained in:
Henrik Friedrichsen
2022-12-28 14:34:17 +01:00
parent cf78f1aed3
commit 93816af654
5 changed files with 7 additions and 9 deletions

View File

@@ -156,7 +156,7 @@ fn get_metadata(playable: Option<Playable>, spotify: Spotify, library: Arc<Libra
true => 1.0,
false => 0.0,
})
.unwrap_or(0.0) as f64,
.unwrap_or(0.0),
)),
);

View File

@@ -118,9 +118,7 @@ impl WebApi {
.header("Retry-After")
.and_then(|v| v.parse::<u64>().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 => {

View File

@@ -50,7 +50,7 @@ impl<I: ListItem + Clone> ApiResult<I> {
}
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<I>) {
@@ -66,7 +66,7 @@ impl<I: ListItem + Clone> ApiResult<I> {
}
pub fn next(&self) -> Option<Vec<I>> {
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) {

View File

@@ -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));
}
_ => {}

View File

@@ -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())?;