diff --git a/src/system.rs b/src/system.rs index 3a4ab9b6..bd8b7956 100644 --- a/src/system.rs +++ b/src/system.rs @@ -754,27 +754,43 @@ macro_rules! system { value: self.value.min(other.value), } } + } - /// f{32,64}: Restrict a value to a certain interval unless it is NaN. - /// Ord: Restrict a value to a certain interval. - #[must_use = "method returns a new number and does not mutate the original value"] - #[inline(always)] - pub fn clamp(self, min: Self, max: Self) -> Self - where - V: $crate::num::Float, - { - Quantity { - dimension: $crate::lib::marker::PhantomData, - units: $crate::lib::marker::PhantomData, - value: self.value.clamp(min.value, max.value), + mod float { + storage_types! { + types: Float; + + use super::super::*; + + impl Quantity + where + D: Dimension + ?Sized, + U: Units + ?Sized, + { + + /// f{32,64}: Restrict a value to a certain interval unless it is NaN. + /// Ord: Restrict a value to a certain interval. + #[must_use = "method returns a new number and does not mutate the original value"] + #[inline(always)] + pub fn clamp(self, min: Self, max: Self) -> Self + where + V: $crate::num::Float, + { + Quantity { + dimension: $crate::lib::marker::PhantomData, + units: $crate::lib::marker::PhantomData, + value: self.value.clamp(min.value, max.value), + } + } } } } + // Explicitly definte floating point methods for float and complex storage types. // `Complex` doesn't implement `Float`/`FloatCore`, but it does implement these methods // when the underlying type, `T`, implements `FloatCore`. - mod float { + mod float_and_complex { storage_types! { types: Float, Complex;