#[derive(Ord, PartialOrd, Eq, PartialEq, Copy, Clone, Debug)]
#[repr(u8)]
pub enum ValueResult {
Stop,
MoreValues,
}
impl From<bool> for ValueResult {
#[inline]
fn from(value: bool) -> Self {
if !value {
Self::Stop
} else {
Self::MoreValues
}
}
}
#[derive(Ord, PartialOrd, Eq, PartialEq, Copy, Clone, Debug)]
#[repr(u8)]
pub enum GeneratorResult {
Stopped,
Complete,
}
impl From<bool> for GeneratorResult {
#[inline]
fn from(b: bool) -> Self {
if !b {
Self::Stopped
} else {
Self::Complete
}
}
}
#[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq)]
pub enum TryReduction<T> {
Complete(T),
Partial(T),
}
impl<T> TryReduction<T> {
#[inline]
pub fn is_complete(&self) -> bool {
matches!(self, TryReduction::Complete(_))
}
#[inline]
pub fn is_partial(&self) -> bool {
matches!(self, TryReduction::Partial(_))
}
#[inline]
pub fn unwrap(self) -> T {
match self {
TryReduction::Complete(x) => x,
TryReduction::Partial(x) => x,
}
}
}