Fix clippy lints for rust 1.75 (#79)

Closes #76

Reviewed-on: #79
This commit is contained in:
Wojciech Kozlowski 2024-01-05 21:25:55 +01:00
parent 62d6c43e3c
commit 74f7da20e6
3 changed files with 11 additions and 16 deletions

View File

@ -222,7 +222,7 @@ pub struct Track {
impl PartialOrd for Track {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.id.partial_cmp(&other.id)
Some(self.cmp(other))
}
}
@ -255,7 +255,7 @@ pub struct Album {
impl PartialOrd for Album {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.id.partial_cmp(&other.id)
Some(self.cmp(other))
}
}
@ -309,7 +309,7 @@ pub struct Artist {
impl PartialOrd for Artist {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.id.partial_cmp(&other.id)
Some(self.cmp(other))
}
}

View File

@ -151,6 +151,7 @@ mod tests {
let io_err: Error = io::Error::new(io::ErrorKind::Interrupted, "Interrupted").into();
let inv_err = Error::Invalid(String::from("Invalid"));
let int_err: Error = "five".parse::<u32>().unwrap_err().into();
#[allow(invalid_from_utf8)]
let utf_err: Error = std::str::from_utf8(b"\xe2\x28\xa1").unwrap_err().into();
assert!(!exe_err.to_string().is_empty());

View File

@ -96,7 +96,7 @@ impl AlbumSelection {
let track: TrackSelection;
if let Some(albums) = albums {
state.select(if !albums.is_empty() { Some(0) } else { None });
track = TrackSelection::initialise(albums.get(0).map(|a| a.tracks.as_slice()));
track = TrackSelection::initialise(albums.first().map(|a| a.tracks.as_slice()));
} else {
state.select(None);
track = TrackSelection::initialise(None);
@ -143,7 +143,7 @@ impl ArtistSelection {
let album: AlbumSelection;
if let Some(artists) = artists {
state.select(if !artists.is_empty() { Some(0) } else { None });
album = AlbumSelection::initialise(artists.get(0).map(|a| a.albums.as_slice()));
album = AlbumSelection::initialise(artists.first().map(|a| a.albums.as_slice()));
} else {
state.select(None);
album = AlbumSelection::initialise(None);
@ -417,7 +417,7 @@ impl<'a> ArtistOverlay<'a> {
opt_vec
.map(|vec| {
if vec.len() < 2 {
vec.get(0).map(|item| item.url()).unwrap_or("").to_string()
vec.first().map(|item| item.url()).unwrap_or("").to_string()
} else {
let indent = format!("\n{indent}");
let list = vec
@ -474,9 +474,7 @@ impl<'a, 'b> AlbumState<'a, 'b> {
"Title: {}\n\
Year: {}",
album.map(|a| a.id.title.as_str()).unwrap_or(""),
album
.map(|a| a.id.year.to_string())
.unwrap_or_else(|| "".to_string()),
album.map(|a| a.id.year.to_string()).unwrap_or_default(),
));
AlbumState {
@ -510,19 +508,15 @@ impl<'a, 'b> TrackState<'a, 'b> {
Title: {}\n\
Artist: {}\n\
Quality: {}",
track
.map(|t| t.id.number.to_string())
.unwrap_or_else(|| "".to_string()),
track.map(|t| t.id.number.to_string()).unwrap_or_default(),
track.map(|t| t.id.title.as_str()).unwrap_or(""),
track
.map(|t| t.artist.join("; "))
.unwrap_or_else(|| "".to_string()),
track.map(|t| t.artist.join("; ")).unwrap_or_default(),
track
.map(|t| match t.quality.format {
Format::Flac => "FLAC".to_string(),
Format::Mp3 => format!("MP3 {}kbps", t.quality.bitrate),
})
.unwrap_or_else(|| "".to_string()),
.unwrap_or_default(),
));
TrackState {