mirror of
https://github.com/lsd-rs/lsd
synced 2024-12-14 06:02:36 +00:00
Redo "Bad" enum as Invalid without internal data
This commit is contained in:
parent
42dfa7d391
commit
820b41a7ef
1 changed files with 4 additions and 4 deletions
|
@ -9,7 +9,7 @@ use std::time::SystemTime;
|
|||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub enum Date {
|
||||
Date(DateTime<Local>),
|
||||
Bad(String),
|
||||
Invalid,
|
||||
}
|
||||
|
||||
// Note that this is split from the From for Metadata so we can test this one (as we can't mock Metadata)
|
||||
|
@ -21,7 +21,7 @@ impl<'a> From<SystemTime> for Date {
|
|||
if let Ok(time) = res {
|
||||
Date::Date(time)
|
||||
} else {
|
||||
Date::Bad(format!("Bad {:?}", res))
|
||||
Date::Invalid
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ impl Date {
|
|||
DateFlag::Formatted(format) => val.format(format).to_string(),
|
||||
}
|
||||
} else {
|
||||
String::from("invalid time")
|
||||
String::from("-")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -322,7 +322,7 @@ mod test {
|
|||
flags.date = DateFlag::Date;
|
||||
|
||||
assert_eq!(
|
||||
"invalid time".to_string().with(Color::AnsiValue(36)),
|
||||
"-".to_string().with(Color::AnsiValue(36)),
|
||||
date.render(&colors, &flags)
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue