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 rust-lang#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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading

2 comments on commit 876eb93

@alexcrichton
Copy link

Choose a reason for hiding this comment

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

r+

@brendanzab
Copy link
Owner Author

Choose a reason for hiding this comment

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

@bors: retry

Please sign in to comment.