use core::cmp;
#[derive(Clone, Copy)]
pub struct DefMinMax<T> {
def: T,
#[allow(dead_code)]
min: T,
#[allow(dead_code)]
max: T,
}
impl<T> DefMinMax<T> {
pub const fn new(def: T, min: T, max: T) -> Self {
Self { def, min, max }
}
pub fn default(self) -> T {
self.def
}
#[allow(dead_code)]
pub fn limit(self, value: T) -> T
where
T: Ord,
{
cmp::max(self.min, cmp::min(self.max, value))
}
}