forked from janek/mostr
fix(task): omit duplicated state name
This commit is contained in:
parent
1251f54789
commit
66fc702538
|
@ -185,13 +185,15 @@ impl TaskState {
|
||||||
}
|
}
|
||||||
impl fmt::Display for TaskState {
|
impl fmt::Display for TaskState {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
let state_str = self.state.to_string();
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"{}{}",
|
"{}",
|
||||||
self.state,
|
|
||||||
self.name
|
self.name
|
||||||
.as_ref()
|
.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))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue