Skip to content

Commit 7e47932

Browse files
committed
directly implement Display instead of ToString, satiate clippy
1 parent 3c4c3bf commit 7e47932

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/app.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@ impl FromStr for DiffType {
7979
}
8080
}
8181

82-
impl ToString for DiffType {
83-
fn to_string(&self) -> String {
84-
match self {
82+
impl std::fmt::Display for DiffType {
83+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
84+
let s = match self {
8585
DiffType::Added => "+",
8686
DiffType::Deleted => "-",
8787
DiffType::Modified => "m",
8888
DiffType::Renamed => "r",
89-
}
90-
.to_string()
89+
};
90+
write!(f, "{}", s)
9191
}
9292
}
9393

src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ fn main() {
7676
});
7777
}
7878

79-
fn setup_logger(log_level: &String) {
80-
let level = match log_level.as_str() {
79+
fn setup_logger(log_level: &str) {
80+
let level = match log_level {
8181
"error" => log::LevelFilter::Error,
8282
"warn" => log::LevelFilter::Warn,
8383
"info" => log::LevelFilter::Info,

src/ui.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,12 @@ fn draw_files<B: Backend>(f: &mut Frame<B>, target: Rect, app: &mut App) {
290290
let style = Style::default().fg(item.diff_type.to_color());
291291
FileListItem::new(
292292
Span::styled(&item.file, style),
293-
Span::styled(format!("{} ", item.diff_type.to_string()), style),
293+
Span::styled(format!("{} ", item.diff_type), style),
294294
)
295295
} else {
296296
FileListItem::new(
297297
Span::raw(&item.file),
298-
Span::raw(format!("{} ", item.diff_type.to_string())),
298+
Span::raw(format!("{} ", item.diff_type)),
299299
)
300300
}
301301
})

0 commit comments

Comments
 (0)