Merge "Replace impl ToString with impl Display" into main

This commit is contained in:
Treehugger Robot
2024-05-10 18:32:41 +00:00
committed by Gerrit Code Review

View File

@@ -33,12 +33,12 @@ enum FlagPermission {
ReadWrite, ReadWrite,
} }
impl ToString for FlagPermission { impl std::fmt::Display for FlagPermission {
fn to_string(&self) -> String { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match &self { write!(f, "{}", match &self {
Self::ReadOnly => "read-only".into(), Self::ReadOnly => "read-only",
Self::ReadWrite => "read-write".into(), Self::ReadWrite => "read-write",
} })
} }
} }
@@ -48,12 +48,12 @@ enum ValuePickedFrom {
Server, Server,
} }
impl ToString for ValuePickedFrom { impl std::fmt::Display for ValuePickedFrom {
fn to_string(&self) -> String { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match &self { write!(f, "{}", match &self {
Self::Default => "default".into(), Self::Default => "default",
Self::Server => "server".into(), Self::Server => "server",
} })
} }
} }
@@ -75,12 +75,12 @@ impl TryFrom<&str> for FlagValue {
} }
} }
impl ToString for FlagValue { impl std::fmt::Display for FlagValue {
fn to_string(&self) -> String { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match &self { write!(f, "{}", match &self {
Self::Enabled => "enabled".into(), Self::Enabled => "enabled",
Self::Disabled => "disabled".into(), Self::Disabled => "disabled",
} })
} }
} }
@@ -103,7 +103,7 @@ impl Flag {
fn display_staged_value(&self) -> String { fn display_staged_value(&self) -> String {
match self.staged_value { match self.staged_value {
Some(v) => format!("(->{})", v.to_string()), Some(v) => format!("(->{})", v),
None => "-".to_string(), None => "-".to_string(),
} }
} }