Use Display instead of custom to_string

This commit is contained in:
Marshall Bowers 2023-10-26 09:30:21 +02:00
parent 28ef30f7a2
commit 9c10152c89

View file

@ -26,13 +26,17 @@ pub enum FileSystemStatus {
Deleted,
}
impl FileSystemStatus {
pub fn to_string(&self) -> String {
match self {
Self::None => "None".to_string(),
Self::Conflict => "Conflict".to_string(),
Self::Deleted => "Deleted".to_string(),
}
impl std::fmt::Display for FileSystemStatus {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
match self {
Self::None => "None",
Self::Conflict => "Conflict",
Self::Deleted => "Deleted",
}
)
}
}
@ -48,17 +52,6 @@ pub enum GitStatus {
}
impl GitStatus {
pub fn to_string(&self) -> String {
match self {
Self::None => "None".to_string(),
Self::Created => "Created".to_string(),
Self::Modified => "Modified".to_string(),
Self::Deleted => "Deleted".to_string(),
Self::Conflict => "Conflict".to_string(),
Self::Renamed => "Renamed".to_string(),
}
}
pub fn hsla(&self, cx: &WindowContext) -> Hsla {
let theme = theme(cx);
@ -73,6 +66,23 @@ impl GitStatus {
}
}
impl std::fmt::Display for GitStatus {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
match self {
Self::None => "None",
Self::Created => "Created",
Self::Modified => "Modified",
Self::Deleted => "Deleted",
Self::Conflict => "Conflict",
Self::Renamed => "Renamed",
}
)
}
}
#[derive(Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, EnumIter)]
pub enum DiagnosticStatus {
#[default]