about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJacob Kiesel <kieseljake@live.com>2022-09-17 18:09:50 -0600
committerJacob Kiesel <kieseljake@live.com>2022-10-03 09:39:37 -0600
commitc7f54daaf44b16469193b03694360153c82aab08 (patch)
tree4440a35e22daeb6dd8b9e98db45beeafabedd315
parent98ad6a5519651af36e246c0335c964dd52c554ba (diff)
downloadrust-c7f54daaf44b16469193b03694360153c82aab08.tar.gz
rust-c7f54daaf44b16469193b03694360153c82aab08.zip
Add better assert messages for f32/f64 clamps
-rw-r--r--library/core/src/num/f32.rs2
-rw-r--r--library/core/src/num/f64.rs2
2 files changed, 2 insertions, 2 deletions
diff --git a/library/core/src/num/f32.rs b/library/core/src/num/f32.rs
index 2c6a0ba64f2..d946f6547b0 100644
--- a/library/core/src/num/f32.rs
+++ b/library/core/src/num/f32.rs
@@ -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;
         }
diff --git a/library/core/src/num/f64.rs b/library/core/src/num/f64.rs
index fd3c18ce29b..b96af86aaba 100644
--- a/library/core/src/num/f64.rs
+++ b/library/core/src/num/f64.rs
@@ -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;
         }