diff --git a/crates/bevy_utils/src/float_ord.rs b/crates/bevy_utils/src/float_ord.rs index 45832198ad4f1..c2b7642b196c4 100644 --- a/crates/bevy_utils/src/float_ord.rs +++ b/crates/bevy_utils/src/float_ord.rs @@ -13,25 +13,13 @@ 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) } } 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.cmp(other) == Ordering::Equal } }