Auto merge of #101959 - Xaeroxe:clamp-better-assert, r=ChrisDenton

Add better assert messages for f32/f64 clamps
This commit is contained in:
bors 2023-04-14 10:44:36 +00:00
commit 3e565f1a27
2 changed files with 2 additions and 2 deletions

View File

@ -1391,7 +1391,7 @@ impl f32 {
#[stable(feature = "clamp", since = "1.50.0")] #[stable(feature = "clamp", since = "1.50.0")]
#[inline] #[inline]
pub fn clamp(mut self, min: f32, max: f32) -> f32 { pub fn clamp(mut self, min: f32, max: f32) -> f32 {
assert!(min <= max); assert!(min <= max, "min > max, or either was NaN. min = {min:?}, max = {max:?}");
if self < min { if self < min {
self = min; self = min;
} }

View File

@ -1389,7 +1389,7 @@ impl f64 {
#[stable(feature = "clamp", since = "1.50.0")] #[stable(feature = "clamp", since = "1.50.0")]
#[inline] #[inline]
pub fn clamp(mut self, min: f64, max: f64) -> f64 { pub fn clamp(mut self, min: f64, max: f64) -> f64 {
assert!(min <= max); assert!(min <= max, "min > max, or either was NaN. min = {min:?}, max = {max:?}");
if self < min { if self < min {
self = min; self = min;
} }