diff options
author | Tim Oram <dev@mitmaro.ca> | 2024-02-15 20:17:41 -0330 |
---|---|---|
committer | Tim Oram <dev@mitmaro.ca> | 2024-02-15 20:27:06 -0330 |
commit | c70d67da1c07a35406bed775cb681e95c7123d9c (patch) | |
tree | 5dc50a07f29c1abbc0126bd3e163f1bb4a9fb467 | |
parent | 88d10ee0e2d51e8a04e9c2a08157eb4ed0fac2bd (diff) |
Convert last ToString to Display
-rw-r--r-- | src/modules/insert.rs | 2 | ||||
-rw-r--r-- | src/modules/insert/line_type.rs | 20 |
2 files changed, 12 insertions, 10 deletions
diff --git a/src/modules/insert.rs b/src/modules/insert.rs index f4bab79..35bf9a5 100644 --- a/src/modules/insert.rs +++ b/src/modules/insert.rs @@ -74,7 +74,7 @@ impl Module for Insert { } else { self.line_type = action.clone(); - self.edit.set_label(format!("{} ", action.to_string()).as_str()); + self.edit.set_label(format!("{action} ").as_str()); self.state = InsertState::Edit; } } diff --git a/src/modules/insert/line_type.rs b/src/modules/insert/line_type.rs index 3b8b86d..91cd603 100644 --- a/src/modules/insert/line_type.rs +++ b/src/modules/insert/line_type.rs @@ -1,3 +1,5 @@ +use std::fmt::Display; + #[derive(Clone, Debug, PartialEq, Eq)] pub(crate) enum LineType { Cancel, @@ -9,16 +11,16 @@ pub(crate) enum LineType { UpdateRef, } -impl ToString for LineType { - fn to_string(&self) -> String { +impl Display for LineType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match *self { - Self::Cancel => String::from("<cancel>"), - Self::Pick => String::from("pick"), - Self::Exec => String::from("exec"), - Self::Label => String::from("label"), - Self::Merge => String::from("merge"), - Self::Reset => String::from("reset"), - Self::UpdateRef => String::from("update-ref"), + Self::Cancel => write!(f, "<cancel>"), + Self::Pick => write!(f, "pick"), + Self::Exec => write!(f, "exec"), + Self::Label => write!(f, "label"), + Self::Merge => write!(f, "merge"), + Self::Reset => write!(f, "reset"), + Self::UpdateRef => write!(f, "update-ref"), } } } |