use core::cmp::Ordering;
use crate::fitness::FitnessValue;
impl FitnessValue for f32 {
fn compare(&self, rhs: &Self) -> Ordering {
assert!(
self.is_finite() && rhs.is_finite(),
"values being compared need to be finite. comparing '{}' with '{}'",
self,
rhs
);
#[allow(clippy::expect_used)]
self.partial_cmp(rhs).expect("both values should be finite")
}
}
impl FitnessValue for f64 {
fn compare(&self, rhs: &Self) -> Ordering {
assert!(
self.is_finite() && rhs.is_finite(),
"values being compared need to be finite. comparing '{}' with '{}'",
self,
rhs
);
#[allow(clippy::expect_used)]
self.partial_cmp(rhs).expect("both values should be finite")
}
}