Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ impl<T: Clone + Integer> Ord for Ratio<T> {

// With equal numerators, the denominators can be inversely compared
if self.numer == other.numer {
if T::is_zero(self.numer()) {
Comment thread
maxbla marked this conversation as resolved.
Outdated
return cmp::Ordering::Equal;
}
let ord = self.denom.cmp(&other.denom);
return if self.numer < T::zero() {
ord
Expand Down Expand Up @@ -1446,6 +1449,9 @@ mod test {

assert!(_0 >= _0 && _1 >= _1);
assert!(_1 >= _0 && !(_0 >= _1));

let _0_2: Rational = Ratio::new_raw(0, 2);
assert_eq!(_0, _0_2);
}

#[test]
Expand Down Expand Up @@ -1538,7 +1544,7 @@ mod test {

mod arith {
use super::super::{Ratio, Rational};
use super::{_0, _1, _1_2, _2, _3_2, _NEG1_2, to_big};
use super::{to_big, _0, _1, _1_2, _2, _3_2, _NEG1_2};
Comment thread
cuviper marked this conversation as resolved.
use traits::{CheckedAdd, CheckedDiv, CheckedMul, CheckedSub};

#[test]
Expand Down