use std::time::SystemTime;
pub trait WallClock: Send + Sync {
#[must_use = "the sampled wall-clock time should be used"]
fn now(&self) -> SystemTime;
}
impl<T> WallClock for &T
where
T: WallClock + ?Sized,
{
#[inline(always)]
fn now(&self) -> SystemTime {
<T as WallClock>::now(*self)
}
}
impl<T> WallClock for std::sync::Arc<T>
where
T: WallClock + ?Sized,
{
#[inline(always)]
fn now(&self) -> SystemTime {
self.as_ref().now()
}
}
impl<T> WallClock for Box<T>
where
T: WallClock + ?Sized,
{
#[inline(always)]
fn now(&self) -> SystemTime {
self.as_ref().now()
}
}