exa/src/output/render/times.rs
Benjamin Sago 002080cde8 Clippy pedantic lints
This commit fixes a couple of Clippy warnings, and adds the list of lints we're OK with.

It does raise some important warnings, such as those to do with casting, which aren't allowed so they can be fixed later.
2020-10-13 01:46:17 +01:00

31 lines
731 B
Rust

use std::time::SystemTime;
use datetime::TimeZone;
use ansi_term::Style;
use crate::output::cell::TextCell;
use crate::output::time::TimeFormat;
pub trait Render {
fn render(self, style: Style, tz: &Option<TimeZone>, format: TimeFormat) -> TextCell;
}
impl Render for Option<SystemTime> {
fn render(self, style: Style, tz: &Option<TimeZone>, format: TimeFormat) -> TextCell {
let datestamp = if let Some(time) = self {
if let Some(ref tz) = tz {
format.format_zoned(time, tz)
}
else {
format.format_local(time)
}
}
else {
String::from("-")
};
TextCell::paint(style, datestamp)
}
}