//! Newtypes to use floating numbers in sorting algs use std::cmp::Ordering; /// Defaults to `Ordering::Less` if the wrapped value can't be compared #[derive(PartialEq, PartialOrd)] #[repr(transparent)] pub struct DefaultLess(pub T); // Not ideal, but `Ord` requires `Eq`, so... impl Eq for DefaultLess {} #[allow(clippy::derive_ord_xor_partial_ord)] impl Ord for DefaultLess { fn cmp(&self, other: &Self) -> Ordering { self.partial_cmp(other).unwrap_or(Ordering::Less) } }