#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct Version(usize);
impl Version {
pub const INITIAL: Self = Version(0);
pub const STEP: usize = 2;
#[inline]
pub fn decrement(&mut self) {
self.0 = self.0.wrapping_sub(Self::STEP);
}
pub fn inner(&self) -> usize {
self.0
}
}
#[derive(Copy, Clone, Debug)]
pub struct StateSnapshot(usize);
impl StateSnapshot {
pub const CLOSED_BIT: usize = 1;
pub fn from_usize(value: usize) -> Self {
StateSnapshot(value)
}
#[inline]
pub fn version(self) -> Version {
Version(self.0 & !Self::CLOSED_BIT)
}
#[inline]
pub fn is_closed(self) -> bool {
(self.0 & Self::CLOSED_BIT) == Self::CLOSED_BIT
}
}