A very simple Stopwatch for the command line
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
498 B

use std::convert::From;
use std::{fmt, time};
#[derive(Debug, Clone)]
pub struct FmtDuration(time::Duration);
impl fmt::Display for FmtDuration {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
let secs = self.0.as_secs();
let millis = self.0.subsec_millis();
write!(f, "{:02}:{:02}:{:03}", secs / 60, secs % 60, millis)
}
}
impl From<time::Duration> for FmtDuration {
fn from(dur: time::Duration) -> Self {
FmtDuration(dur)
}
}