forked from janek/mostr
1
0
Fork 0

fix(task): omit duplicated state name

This commit is contained in:
xeruf 2024-07-29 14:16:37 +03:00
parent 1251f54789
commit 66fc702538
1 changed files with 5 additions and 3 deletions

View File

@ -185,13 +185,15 @@ impl TaskState {
}
impl fmt::Display for TaskState {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let state_str = self.state.to_string();
write!(
f,
"{}{}",
self.state,
"{}",
self.name
.as_ref()
.map_or(String::new(), |s| format!(": {}", s))
.map(|s| s.trim())
.filter(|s| !s.eq_ignore_ascii_case(&state_str))
.map_or(state_str, |s| format!("{}: {}", self.state, s))
)
}
}