Skip to content

Commit

Permalink
replace trait Display to as_str()
Browse files Browse the repository at this point in the history
  • Loading branch information
syrflover committed Oct 25, 2023
1 parent f95be2d commit 3f7c798
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/model/tag.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::fmt::Display;

use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
Expand All @@ -20,21 +18,25 @@ pub enum TagKind {
Misc,
}

impl Display for TagKind {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
impl TagKind {
pub fn as_str(&self) -> &str {
self.as_ref()
}
}

impl AsRef<str> for TagKind {
fn as_ref(&self) -> &str {
use TagKind::*;

let x = match self {
match self {
Artist => "artist",
Group => "group",
Series => "series",
Character => "character",
Female => "female",
Male => "male",
Misc => "misc",
};

write!(f, "{x}")
}
}
}

Expand Down

0 comments on commit 3f7c798

Please sign in to comment.