Sort albums by month if two releases of the same artist happen in the same year #155
@ -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<u8> for AlbumMonth {
|
||||
fn from(value: u8) -> Self {
|
||||
match value {
|
||||
|
@ -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<dyn Any + Send>),
|
||||
}
|
||||
|
||||
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<io::Error> 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]
|
||||
|
Loading…
Reference in New Issue
Block a user