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);
|
pub struct AlbumSeq(pub u8);
|
||||||
|
|
||||||
#[repr(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 {
|
pub enum AlbumMonth {
|
||||||
|
#[default]
|
||||||
None = 0,
|
None = 0,
|
||||||
January = 1,
|
January = 1,
|
||||||
February = 2,
|
February = 2,
|
||||||
@ -62,12 +63,6 @@ pub enum AlbumMonth {
|
|||||||
December = 12,
|
December = 12,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for AlbumMonth {
|
|
||||||
fn default() -> Self {
|
|
||||||
AlbumMonth::None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<u8> for AlbumMonth {
|
impl From<u8> for AlbumMonth {
|
||||||
fn from(value: u8) -> Self {
|
fn from(value: u8) -> Self {
|
||||||
match value {
|
match value {
|
||||||
|
@ -18,7 +18,6 @@ use crossterm::{
|
|||||||
use ratatui::{backend::Backend, Terminal};
|
use ratatui::{backend::Backend, Terminal};
|
||||||
use std::{
|
use std::{
|
||||||
marker::PhantomData,
|
marker::PhantomData,
|
||||||
ptr,
|
|
||||||
{any::Any, io},
|
{any::Any, io},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -37,27 +36,6 @@ pub enum Error {
|
|||||||
ListenerPanic(Box<dyn Any + Send>),
|
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 {
|
impl From<io::Error> for Error {
|
||||||
fn from(err: io::Error) -> Error {
|
fn from(err: io::Error) -> Error {
|
||||||
Error::Io(err.to_string())
|
Error::Io(err.to_string())
|
||||||
@ -277,10 +255,9 @@ mod tests {
|
|||||||
|
|
||||||
let result = Tui::main(terminal, app, ui, handler, listener);
|
let result = Tui::main(terminal, app, ui, handler, listener);
|
||||||
assert!(result.is_err());
|
assert!(result.is_err());
|
||||||
assert_eq!(
|
|
||||||
result.unwrap_err(),
|
let recv_err = EventError::Recv.to_string();
|
||||||
Error::Event(EventError::Recv.to_string())
|
matches!(result.unwrap_err(), Error::Event(err) if err == recv_err);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -304,8 +281,9 @@ mod tests {
|
|||||||
let result = Tui::main(terminal, app, ui, handler, listener);
|
let result = Tui::main(terminal, app, ui, handler, listener);
|
||||||
assert!(result.is_err());
|
assert!(result.is_err());
|
||||||
|
|
||||||
let error = EventError::Io(io::Error::new(io::ErrorKind::Interrupted, "error"));
|
let io_err =
|
||||||
assert_eq!(result.unwrap_err(), Error::Event(error.to_string()));
|
EventError::Io(io::Error::new(io::ErrorKind::Interrupted, "error")).to_string();
|
||||||
|
matches!(result.unwrap_err(), Error::Event(err) if err == io_err);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Loading…
Reference in New Issue
Block a user