use std::fmt::Debug;
use std::fmt::Display;
use std::fmt::Formatter;
use std::fmt::Result as FmtResult;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Observation<Q> {
Exact(
Q,
),
AtLeast(
Q,
),
}
impl<Q> Display for Observation<Q>
where
Q: Display,
{
fn fmt(&self, formatter: &mut Formatter<'_>) -> FmtResult {
match self {
Self::Exact(value) => write!(formatter, "exactly {value}"),
Self::AtLeast(value) => write!(formatter, "at least {value}"),
}
}
}
impl<Q> Observation<Q>
where
Q: Copy + Debug,
{
#[inline(always)]
#[must_use]
pub const fn exact(self) -> Option<Q> {
match self {
Self::Exact(value) => Some(value),
Self::AtLeast(_) => None,
}
}
#[inline(always)]
#[must_use]
pub const fn lower_bound(self) -> Q {
match self {
Self::Exact(value) | Self::AtLeast(value) => value,
}
}
}