We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Float::clamp
1 parent 2957044 commit 1a44ffbCopy full SHA for 1a44ffb
src/float.rs
@@ -1531,6 +1531,8 @@ pub trait Float: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
1531
1532
/// Clamps a value between a min and max.
1533
///
1534
+ /// **Panics** in debug mode if `!(min <= max)`.
1535
+ ///
1536
/// ```
1537
/// use num_traits::Float;
1538
@@ -1540,7 +1542,9 @@ pub trait Float: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
1540
1542
1541
1543
/// assert_eq!(x.clamp(y, z), 2.0);
1544
- fn clamp(self, min: Self, max: Self) -> Self;
1545
+ fn clamp(self, min: Self, max: Self) -> Self {
1546
+ crate::clamp(self, min, max)
1547
+ }
1548
1549
/// The positive difference of two numbers.
1550
0 commit comments