diff --git a/src/core/collection/album.rs b/src/core/collection/album.rs index 9a692e1..d0222d4 100644 --- a/src/core/collection/album.rs +++ b/src/core/collection/album.rs @@ -45,8 +45,9 @@ pub struct AlbumDate { pub struct AlbumSeq(pub u8); #[repr(u8)] -#[derive(Clone, Copy, Debug, PartialEq, PartialOrd, Ord, Eq, Hash)] +#[derive(Clone, Copy, Debug, Default, PartialEq, PartialOrd, Ord, Eq, Hash)] pub enum AlbumMonth { + #[default] None = 0, January = 1, February = 2, @@ -62,12 +63,6 @@ pub enum AlbumMonth { December = 12, } -impl Default for AlbumMonth { - fn default() -> Self { - AlbumMonth::None - } -} - impl From for AlbumMonth { fn from(value: u8) -> Self { match value { diff --git a/src/tui/mod.rs b/src/tui/mod.rs index c43e01a..a559391 100644 --- a/src/tui/mod.rs +++ b/src/tui/mod.rs @@ -18,7 +18,6 @@ use crossterm::{ use ratatui::{backend::Backend, Terminal}; use std::{ marker::PhantomData, - ptr, {any::Any, io}, }; @@ -37,27 +36,6 @@ pub enum Error { ListenerPanic(Box), } -impl Eq for Error {} - -impl PartialEq for Error { - fn eq(&self, other: &Self) -> bool { - match self { - Error::Io(this) => match other { - Error::Io(other) => this == other, - _ => false, - }, - Error::Event(this) => match other { - Error::Event(other) => this == other, - _ => false, - }, - Error::ListenerPanic(this) => match other { - Error::ListenerPanic(other) => ptr::eq(this.as_ref(), other.as_ref()), - _ => false, - }, - } - } -} - impl From for Error { fn from(err: io::Error) -> Error { Error::Io(err.to_string()) @@ -277,10 +255,9 @@ mod tests { let result = Tui::main(terminal, app, ui, handler, listener); assert!(result.is_err()); - assert_eq!( - result.unwrap_err(), - Error::Event(EventError::Recv.to_string()) - ); + + let recv_err = EventError::Recv.to_string(); + matches!(result.unwrap_err(), Error::Event(err) if err == recv_err); } #[test] @@ -304,8 +281,9 @@ mod tests { let result = Tui::main(terminal, app, ui, handler, listener); assert!(result.is_err()); - let error = EventError::Io(io::Error::new(io::ErrorKind::Interrupted, "error")); - assert_eq!(result.unwrap_err(), Error::Event(error.to_string())); + let io_err = + EventError::Io(io::Error::new(io::ErrorKind::Interrupted, "error")).to_string(); + matches!(result.unwrap_err(), Error::Event(err) if err == io_err); } #[test]