diff --git a/src/fraction/generic_fraction.rs b/src/fraction/generic_fraction.rs index 768b9017..98cd8f5f 100644 --- a/src/fraction/generic_fraction.rs +++ b/src/fraction/generic_fraction.rs @@ -516,6 +516,25 @@ impl PartialOrd for GenericFraction { } } +impl Ord for GenericFraction { + fn cmp(&self, other: &Self) -> Ordering { + if *self == GenericFraction::NaN { + if *other == GenericFraction::NaN { + Ordering::Equal + } else { + Ordering::Less + } + } else { + if *other == GenericFraction::NaN { + Ordering::Greater + } else { + self.partial_cmp(other).expect("Well when I wrote this the only way partial_cmp() would return None was if one of the argument was NaN, which they weren't in this case.") + } + } + } +} + + impl Neg for GenericFraction { type Output = GenericFraction;