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 @@ pub fn total_cmp(&self, other: &Self) -> crate::cmp::Ordering {
#[stable(feature = "clamp", since = "1.50.0")]
#[inline]
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 {
self = min;
}

View file

@ -1389,7 +1389,7 @@ pub fn total_cmp(&self, other: &Self) -> crate::cmp::Ordering {
#[stable(feature = "clamp", since = "1.50.0")]
#[inline]
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 {
self = min;
}