Skip to content

Commit

Permalink
Auto merge of #101959 - Xaeroxe:clamp-better-assert, r=ChrisDenton
Browse files Browse the repository at this point in the history
Add better assert messages for f32/f64 clamps
  • Loading branch information
bors committed Apr 14, 2023
2 parents 71ef9ec + c7f54da commit 3e565f1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion library/core/src/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1391,7 +1391,7 @@ impl f32 {
#[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;
}
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1389,7 +1389,7 @@ impl f64 {
#[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;
}
Expand Down

0 comments on commit 3e565f1

Please sign in to comment.