use core::time::Duration;
pub trait Instant: Copy + Ord + Sized {
fn checked_add_duration(self, dur: Duration) -> Option<Self>;
fn checked_duration_since(self, earlier: Self) -> Option<Duration>;
}
#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl Instant for std::time::Instant {
#[inline]
fn checked_add_duration(self, dur: Duration) -> Option<Self> {
std::time::Instant::checked_add(&self, dur)
}
#[inline]
fn checked_duration_since(self, earlier: Self) -> Option<Duration> {
std::time::Instant::checked_duration_since(&self, earlier)
}
}
#[cfg(all(test, feature = "std"))]
#[allow(clippy::unwrap_used, clippy::expect_used)]
mod tests;