use hmath::Ratio;
#[derive(Clone)]
pub enum SkipValue {
None,
Automatic,
Manual { from: Ratio, to: Ratio },
}
impl SkipValue {
pub fn none() -> Self {
SkipValue::None
}
pub fn automatic() -> Self {
SkipValue::Automatic
}
pub fn manual<T: TryInto<Ratio>, U: TryInto<Ratio>>(from: T, to: U) -> Self {
let from = from.try_into().unwrap_or(Ratio::zero());
let to = to.try_into().unwrap_or(Ratio::zero());
assert!(from.leq_rat(&to));
SkipValue::Manual {
from, to
}
}
pub(crate) fn is_automatic(&self) -> bool {
match self {
SkipValue::Automatic => true,
_ => false,
}
}
}