use crate::error::Result;
use crate::threshold::Threshold;
#[derive(Debug, Clone, Default)]
pub struct CheckThresholds {
pub max_exact: Option<usize>,
pub max_near: Option<usize>,
pub max_exact_percent: Option<Threshold>,
pub max_near_percent: Option<Threshold>,
}
impl CheckThresholds {
pub fn new(
max_exact: Option<usize>,
max_near: Option<usize>,
max_exact_percent: Option<f64>,
max_near_percent: Option<f64>,
) -> Result<Self> {
Ok(Self {
max_exact,
max_near,
max_exact_percent: max_exact_percent
.map(|value| Threshold::percent("--max-exact-percent", value))
.transpose()?,
max_near_percent: max_near_percent
.map(|value| Threshold::percent("--max-near-percent", value))
.transpose()?,
})
}
#[must_use]
pub const fn is_unbounded(&self) -> bool {
self.max_exact.is_none()
&& self.max_near.is_none()
&& self.max_exact_percent.is_none()
&& self.max_near_percent.is_none()
}
}