From 8765658acf5840469692edfaa102378e3c8dedc4 Mon Sep 17 00:00:00 2001 From: Nico Hunds Date: Mon, 4 Jul 2022 21:29:09 +0200 Subject: [PATCH 1/3] Migrated to f32::total_cmp() function. --- crates/bevy_utils/src/float_ord.rs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/crates/bevy_utils/src/float_ord.rs b/crates/bevy_utils/src/float_ord.rs index 45832198ad4f1..889d5a2444c1f 100644 --- a/crates/bevy_utils/src/float_ord.rs +++ b/crates/bevy_utils/src/float_ord.rs @@ -13,15 +13,7 @@ pub struct FloatOrd(pub f32); #[allow(clippy::derive_ord_xor_partial_ord)] impl Ord for FloatOrd { fn cmp(&self, other: &Self) -> Ordering { - self.0.partial_cmp(&other.0).unwrap_or_else(|| { - if self.0.is_nan() && !other.0.is_nan() { - Ordering::Less - } else if !self.0.is_nan() && other.0.is_nan() { - Ordering::Greater - } else { - Ordering::Equal - } - }) + self.0.total_cmp(&other.0) } } From c52aea5d7b23f590a232b7d276823be88a4e391a Mon Sep 17 00:00:00 2001 From: Nico Hunds Date: Sun, 10 Jul 2022 18:31:03 +0200 Subject: [PATCH 2/3] Based PartialEq.eq() on Ord.cmp() --- crates/bevy_utils/src/float_ord.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/crates/bevy_utils/src/float_ord.rs b/crates/bevy_utils/src/float_ord.rs index 889d5a2444c1f..a6c2d869f8303 100644 --- a/crates/bevy_utils/src/float_ord.rs +++ b/crates/bevy_utils/src/float_ord.rs @@ -19,11 +19,7 @@ impl Ord for FloatOrd { impl PartialEq for FloatOrd { fn eq(&self, other: &Self) -> bool { - if self.0.is_nan() && other.0.is_nan() { - true - } else { - self.0 == other.0 - } + self.0 == other.0 } } From 0deb4554b94d37b9d558b438f917855322360e64 Mon Sep 17 00:00:00 2001 From: Nico Hunds Date: Mon, 11 Jul 2022 09:56:27 +0200 Subject: [PATCH 3/3] Update crates/bevy_utils/src/float_ord.rs Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com> --- crates/bevy_utils/src/float_ord.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_utils/src/float_ord.rs b/crates/bevy_utils/src/float_ord.rs index a6c2d869f8303..c2b7642b196c4 100644 --- a/crates/bevy_utils/src/float_ord.rs +++ b/crates/bevy_utils/src/float_ord.rs @@ -19,7 +19,7 @@ impl Ord for FloatOrd { impl PartialEq for FloatOrd { fn eq(&self, other: &Self) -> bool { - self.0 == other.0 + self.cmp(other) == Ordering::Equal } }