use crate::Ordering;
#[doc = crate::_tags!(runtime time)]
#[doc = crate::_doc_location!("run/time")]
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct RuntimeTick {
ticks: u64,
}
#[rustfmt::skip]
impl RuntimeTick {
pub const fn new(ticks: u64) -> Self { Self { ticks } }
pub const fn ticks(self) -> u64 { self.ticks }
pub const fn tick(&mut self) { self.ticks += 1; }
pub const fn next(self) -> Self { Self { ticks: self.ticks + 1 } }
pub const fn advance_mut(&mut self, delta: u64) { self.ticks += delta; }
pub const fn advanced(self, delta: u64) -> Self { Self { ticks: self.ticks + delta } }
pub const fn delta(self, earlier: Self) -> u64 { self.ticks.saturating_sub(earlier.ticks) }
pub const fn is_after(self, other: Self) -> bool { self.ticks > other.ticks }
pub const fn is_before(self, other: Self) -> bool { self.ticks < other.ticks }
pub const fn eq(self, other: Self) -> bool { self.ticks == other.ticks }
pub const fn cmp(self, other: Self) -> Ordering {
if self.ticks < other.ticks { Ordering::Less }
else if self.ticks > other.ticks { Ordering::Greater }
else { Ordering::Equal }
}
}