Skip to content

Commit

Permalink
Remove lots of numeric traits from the preludes
Browse files Browse the repository at this point in the history
Num, NumCast, Unsigned, Float, Primitive and Int have been removed.
  • Loading branch information
brendanzab committed Nov 12, 2014
1 parent 1dd6b64 commit 93bfb8e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ use std::io::fs::PathExtensions;
use std::io::stdio::StdWriter;
use std::io::{File, ChanReader, ChanWriter};
use std::io;
use std::num::{Int, FloatMath};
use std::os;
use std::string::String;
use std::task::TaskBuilder;
Expand Down
9 changes: 5 additions & 4 deletions stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use std::fmt::Show;
use std::hash::Hash;
use std::io;
use std::mem;
use std::num::{Float, FloatMath};

fn local_cmp<T:Float>(x: T, y: T) -> Ordering {
// arbitrarily decide that NaNs are larger than everything.
Expand Down Expand Up @@ -1042,11 +1043,11 @@ mod tests {
}
#[test]
fn test_sum_f64s() {
assert_eq!([0.5f64, 3.2321f64, 1.5678f64].sum(0.0), 5.2999);
assert_eq!([0.5f64, 3.2321f64, 1.5678f64].sum(), 5.2999);
}
#[test]
fn test_sum_f64_between_ints_that_sum_to_0() {
assert_eq!([1e30f64, 1.2f64, -1e30f64].sum(0.0), 1.2);
assert_eq!([1e30f64, 1.2f64, -1e30f64].sum(), 1.2);
}
}

Expand All @@ -1058,7 +1059,7 @@ mod bench {
#[bench]
pub fn sum_three_items(b: &mut Bencher) {
b.iter(|| {
[1e20f64, 1.5f64, -1e20f64].sum(0.0);
[1e20f64, 1.5f64, -1e20f64].sum();
})
}
#[bench]
Expand All @@ -1067,7 +1068,7 @@ mod bench {
let v = Vec::from_fn(500, |i| nums[i%5]);

b.iter(|| {
v.as_slice().sum(0.0);
v.as_slice().sum();
})
}
}

0 comments on commit 93bfb8e

Please sign in to comment.