use std::io::Result;
use std::time::Duration;
use super::Clock;
pub struct Timer<'c, C: Clock> {
pub start: Duration,
pub clock: &'c C,
}
impl<'c, C: Clock> Timer<'c, C> {
pub fn elapsed(&self) -> Result<Duration> {
let end = self.clock.get_time()?;
return Ok(end - self.start);
}
#[inline(always)]
pub fn end(self) -> Result<Duration> {
return self.elapsed();
}
}