diff options
| author | bors <bors@rust-lang.org> | 2014-01-09 06:26:27 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-01-09 06:26:27 -0800 |
| commit | 1b0f5b23fc08ff22dc513c5f333569b7e8b9313d (patch) | |
| tree | f54117c4c6566f7e5078745cfcb63d3538afd84d /src/libextra | |
| parent | ab9ec6d59a0e5e79e553e0e4570a28ded1ead1aa (diff) | |
| parent | 0232fed174b9f7d227fd70c356ccd226dd47cab1 (diff) | |
| download | rust-1b0f5b23fc08ff22dc513c5f333569b7e8b9313d.tar.gz rust-1b0f5b23fc08ff22dc513c5f333569b7e8b9313d.zip | |
auto merge of #11412 : bjz/rust/num-cleanups, r=alexcrichton
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.
r? @alexcrichton
Diffstat (limited to 'src/libextra')
| -rw-r--r-- | src/libextra/num/complex.rs | 5 | ||||
| -rw-r--r-- | src/libextra/num/rational.rs | 13 |
2 files changed, 8 insertions, 10 deletions
diff --git a/src/libextra/num/complex.rs b/src/libextra/num/complex.rs index b4795c7e66b..47a2e35f028 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`. |
