mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
Auto merge of #101959 - Xaeroxe:clamp-better-assert, r=ChrisDenton
Add better assert messages for f32/f64 clamps
This commit is contained in:
commit
3e565f1a27
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user