Skip to content

Commit

Permalink
Remove Real trait and move methods into Float
Browse files Browse the repository at this point in the history
This is part of the effort to simplify `std::num`, as tracked in issue #10387.
  • Loading branch information
brendanzab committed Feb 16, 2014
1 parent 6fe775e commit 876eb93
Show file tree
Hide file tree
Showing 9 changed files with 501 additions and 511 deletions.
2 changes: 1 addition & 1 deletion src/etc/vim/syntax/rust.vim
Expand Up @@ -85,7 +85,7 @@ syn keyword rustTrait Iterator DoubleEndedIterator RandomAccessIterator Cloneabl
syn keyword rustTrait OrdIterator MutableDoubleEndedIterator ExactSize

syn keyword rustTrait Algebraic Trigonometric Exponential Hyperbolic
syn keyword rustTrait Bitwise Bounded Integer Fractional Real RealExt
syn keyword rustTrait Bitwise Bounded Integer
syn keyword rustTrait Num NumCast CheckedAdd CheckedSub CheckedMul CheckedDiv
syn keyword rustTrait Orderable Signed Unsigned Round
syn keyword rustTrait Primitive Int Float ToStrRadix ToPrimitive FromPrimitive
Expand Down
12 changes: 6 additions & 6 deletions src/libnum/complex.rs
Expand Up @@ -77,15 +77,15 @@ impl<T: Clone + Num> Cmplx<T> {
}
}

impl<T: Clone + Real> Cmplx<T> {
impl<T: Clone + Float> Cmplx<T> {
/// Calculate |self|
#[inline]
pub fn norm(&self) -> T {
self.re.hypot(&self.im)
}
}

impl<T: Clone + Real> Cmplx<T> {
impl<T: Clone + Float> Cmplx<T> {
/// Calculate the principal Arg of self.
#[inline]
pub fn arg(&self) -> T {
Expand Down Expand Up @@ -192,7 +192,7 @@ mod test {
#[allow(non_uppercase_statics)];

use super::{Complex64, Cmplx};
use std::num::{Zero,One,Real};
use std::num::{Zero,One,Float};

pub static _0_0i : Complex64 = Cmplx { re: 0.0, im: 0.0 };
pub static _1_0i : Complex64 = Cmplx { re: 1.0, im: 0.0 };
Expand Down Expand Up @@ -270,9 +270,9 @@ mod test {
assert!((c.arg() - arg).abs() < 1.0e-6)
}
test(_1_0i, 0.0);
test(_1_1i, 0.25 * Real::pi());
test(_neg1_1i, 0.75 * Real::pi());
test(_05_05i, 0.25 * Real::pi());
test(_1_1i, 0.25 * Float::pi());
test(_neg1_1i, 0.75 * Float::pi());
test(_05_05i, 0.25 * Float::pi());
}

#[test]
Expand Down

9 comments on commit 876eb93

@bors
Copy link
Contributor

@bors bors commented on 876eb93 Feb 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at brendanzab@876eb93

@bors
Copy link
Contributor

@bors bors commented on 876eb93 Feb 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging bjz/rust/remove-real = 876eb93 into auto

@bors
Copy link
Contributor

@bors bors commented on 876eb93 Feb 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bjz/rust/remove-real = 876eb93 merged ok, testing candidate = 2a72dd91

@bors
Copy link
Contributor

@bors bors commented on 876eb93 Feb 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 876eb93 Feb 18, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at brendanzab@876eb93

@bors
Copy link
Contributor

@bors bors commented on 876eb93 Feb 18, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging bjz/rust/remove-real = 876eb93 into auto

@bors
Copy link
Contributor

@bors bors commented on 876eb93 Feb 18, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bjz/rust/remove-real = 876eb93 merged ok, testing candidate = b0ce960

@bors
Copy link
Contributor

@bors bors commented on 876eb93 Feb 18, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 876eb93 Feb 18, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = b0ce960

Please sign in to comment.