]> git.lizzy.rs Git - rust.git/blobdiff - src/libnum/rational.rs
auto merge of #16775 : jbcrail/rust/fix-rational-docs, r=pcwalton
[rust.git] / src / libnum / rational.rs
index 59f559cf19369c99e013aa9f0a8b85d7eae92313..0e334544b4b6c1b305576f583fd64b63b65dcf0b 100644 (file)
@@ -21,7 +21,7 @@
 use bigint::{BigInt, BigUint, Sign, Plus, Minus};
 
 /// Represents the ratio between 2 numbers.
-#[deriving(Clone)]
+#[deriving(Clone, Hash)]
 #[allow(missing_doc)]
 pub struct Ratio<T> {
     numer: T,
@@ -380,6 +380,7 @@ mod test {
     use super::{Ratio, Rational, BigRational};
     use std::num::{Zero, One, FromStrRadix, FromPrimitive, ToStrRadix};
     use std::from_str::FromStr;
+    use std::hash::hash;
     use std::num;
 
     pub static _0 : Rational = Ratio { numer: 0, denom: 1};
@@ -751,4 +752,10 @@ fn test_signed() {
         assert!(! _neg1_2.is_positive());
         assert!(! _1_2.is_negative());
     }
+
+    #[test]
+    fn test_hash() {
+        assert!(hash(&_0) != hash(&_1));
+        assert!(hash(&_0) != hash(&_3_2));
+    }
 }