about summary refs log tree commit diff
path: root/src/libextra
diff options
context:
space:
mode:
authorBrendan Zabarauskas <bjzaba@yahoo.com.au>2014-01-09 15:29:09 +1100
committerBrendan Zabarauskas <bjzaba@yahoo.com.au>2014-01-09 15:29:09 +1100
commit0232fed174b9f7d227fd70c356ccd226dd47cab1 (patch)
tree4e7527c80ab2b82fa9a41b3e43b6dad25c216f75 /src/libextra
parent9dece60391943297a734424bde3f04e2fa479729 (diff)
downloadrust-0232fed174b9f7d227fd70c356ccd226dd47cab1.tar.gz
rust-0232fed174b9f7d227fd70c356ccd226dd47cab1.zip
Merge some numeric traits with Real and don't re-export RealExt
The methods contained in `std::num::{Algebraic, Trigonometric, Exponential, Hyperbolic}` have now been moved into `std::num::Real`. This is part of an ongoing effort to simplify `std::num` (see issue #10387).

`std::num::RealExt` has also been removed from the prelude because it is not a commonly used trait.
Diffstat (limited to 'src/libextra')
-rw-r--r--src/libextra/num/complex.rs5
-rw-r--r--src/libextra/num/rational.rs13
2 files changed, 8 insertions, 10 deletions
diff --git a/src/libextra/num/complex.rs b/src/libextra/num/complex.rs
index 58af80fefb7..b1b4bb57d98 100644
--- a/src/libextra/num/complex.rs
+++ b/src/libextra/num/complex.rs
@@ -11,7 +11,6 @@
 
 //! Complex numbers.
 
-
 use std::num::{Zero,One,ToStrRadix};
 
 // FIXME #1284: handle complex NaN & infinity etc. This
@@ -78,7 +77,7 @@ impl<T: Clone + Num> Cmplx<T> {
     }
 }
 
-impl<T: Clone + Algebraic + Num> Cmplx<T> {
+impl<T: Clone + Real> Cmplx<T> {
     /// Calculate |self|
     #[inline]
     pub fn norm(&self) -> T {
@@ -86,7 +85,7 @@ impl<T: Clone + Algebraic + Num> Cmplx<T> {
     }
 }
 
-impl<T: Clone + Trigonometric + Algebraic + Num> Cmplx<T> {
+impl<T: Clone + Real> Cmplx<T> {
     /// Calculate the principal Arg of self.
     #[inline]
     pub fn arg(&self) -> T {
diff --git a/src/libextra/num/rational.rs b/src/libextra/num/rational.rs
index 3ab9f99d5cf..4edccf685e2 100644
--- a/src/libextra/num/rational.rs
+++ b/src/libextra/num/rational.rs
@@ -105,6 +105,12 @@ impl<T: Clone + Integer + Ord>
         ret.reduce();
         ret
     }
+
+    /// Return the reciprocal
+    #[inline]
+    pub fn recip(&self) -> Ratio<T> {
+        Ratio::new_raw(self.denom.clone(), self.numer.clone())
+    }
 }
 
 impl Ratio<BigInt> {
@@ -288,13 +294,6 @@ impl<T: Clone + Integer + Ord>
     }
 }
 
-impl<T: Clone + Integer + Ord> Fractional for Ratio<T> {
-    #[inline]
-    fn recip(&self) -> Ratio<T> {
-        Ratio::new_raw(self.denom.clone(), self.numer.clone())
-    }
-}
-
 /* String conversions */
 impl<T: ToStr> ToStr for Ratio<T> {
     /// Renders as `numer/denom`.