pub const trait RangeExtension<T, F> {
fn get_value_from_percent(&self, percentage: F) -> Option<T>;
fn get_percent_from_value(&self, value: T) -> Option<F>;
}
impl<
T: [const] crate::extensions::TryIntoPatch<F> + Copy,
F: [const] crate::extensions::TryIntoPatch<T>
+ [const] core::ops::Mul<Output = F>
+ [const] core::ops::Div<Output = F>
+ [const] crate::extensions::Round
+ Copy,
> const RangeExtension<T, F> for core::ops::Range<T>
{
fn get_value_from_percent(&self, percentage: F) -> Option<T> {
((self.end.try_into_value()? * percentage).round()).try_into_value()
}
fn get_percent_from_value(&self, value: T) -> Option<F> {
Some((value).try_into_value()? / ((self.end).try_into_value()?))
}
}