Skip to content

Commit c70d67d

Browse files
committed
Convert last ToString to Display
1 parent 88d10ee commit c70d67d

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/modules/insert.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl Module for Insert {
7474
}
7575
else {
7676
self.line_type = action.clone();
77-
self.edit.set_label(format!("{} ", action.to_string()).as_str());
77+
self.edit.set_label(format!("{action} ").as_str());
7878
self.state = InsertState::Edit;
7979
}
8080
}

src/modules/insert/line_type.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::fmt::Display;
2+
13
#[derive(Clone, Debug, PartialEq, Eq)]
24
pub(crate) enum LineType {
35
Cancel,
@@ -9,16 +11,16 @@ pub(crate) enum LineType {
911
UpdateRef,
1012
}
1113

12-
impl ToString for LineType {
13-
fn to_string(&self) -> String {
14+
impl Display for LineType {
15+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1416
match *self {
15-
Self::Cancel => String::from("<cancel>"),
16-
Self::Pick => String::from("pick"),
17-
Self::Exec => String::from("exec"),
18-
Self::Label => String::from("label"),
19-
Self::Merge => String::from("merge"),
20-
Self::Reset => String::from("reset"),
21-
Self::UpdateRef => String::from("update-ref"),
17+
Self::Cancel => write!(f, "<cancel>"),
18+
Self::Pick => write!(f, "pick"),
19+
Self::Exec => write!(f, "exec"),
20+
Self::Label => write!(f, "label"),
21+
Self::Merge => write!(f, "merge"),
22+
Self::Reset => write!(f, "reset"),
23+
Self::UpdateRef => write!(f, "update-ref"),
2224
}
2325
}
2426
}

0 commit comments

Comments
 (0)