Skip to content

Commit 7951cb5

Browse files
committed
---
yaml --- r: 159572 b: refs/heads/auto c: e6db701 h: refs/heads/master v: v3
1 parent 4efec0f commit 7951cb5

File tree

7 files changed

+17
-37
lines changed

7 files changed

+17
-37
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: 8666812dce7e219501642d4aabfd89e6b986834f
13+
refs/heads/auto: e6db701d5b09c169297aaaf2d5d53f64bcb4676e
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/libcore/num/mod.rs

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -271,25 +271,6 @@ signed_float_impl!(f32, f32::NAN, f32::INFINITY, f32::NEG_INFINITY,
271271
signed_float_impl!(f64, f64::NAN, f64::INFINITY, f64::NEG_INFINITY,
272272
intrinsics::fabsf64, intrinsics::copysignf64, fdim)
273273

274-
/// Computes the absolute value.
275-
///
276-
/// For `f32` and `f64`, `NaN` will be returned if the number is `NaN`
277-
///
278-
/// For signed integers, `::MIN` will be returned if the number is `::MIN`.
279-
#[inline(always)]
280-
pub fn abs<T: Signed>(value: T) -> T {
281-
value.abs()
282-
}
283-
284-
/// The positive difference of two numbers.
285-
///
286-
/// Returns zero if `x` is less than or equal to `y`, otherwise the difference
287-
/// between `x` and `y` is returned.
288-
#[inline(always)]
289-
pub fn abs_sub<T: Signed>(x: T, y: T) -> T {
290-
x.abs_sub(y)
291-
}
292-
293274
/// Returns the sign of the number.
294275
///
295276
/// For `f32` and `f64`:
@@ -1560,3 +1541,10 @@ pub trait Float: Signed + Primitive {
15601541
/// Convert degrees to radians.
15611542
fn to_radians(self) -> Self;
15621543
}
1544+
1545+
// DEPRECATED
1546+
1547+
#[deprecated = "Use `Signed::abs`"]
1548+
pub fn abs<T: Signed>(value: T) -> T { value.abs() }
1549+
#[deprecated = "Use `Signed::abs_sub`"]
1550+
pub fn abs_sub<T: Signed>(x: T, y: T) -> T { x.abs_sub(y) }

branches/auto/src/librand/distributions/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ that do not need to record state.
2323
#![experimental]
2424

2525
use core::prelude::*;
26-
use core::num;
2726

2827
use {Rng, Rand};
2928

@@ -243,7 +242,7 @@ fn ziggurat<R:Rng>(
243242
let u = if symmetric {2.0 * f - 1.0} else {f};
244243
let x = u * x_tab[i];
245244

246-
let test_x = if symmetric {num::abs(x)} else {x};
245+
let test_x = if symmetric { x.abs() } else {x};
247246

248247
// algebraically equivalent to |u| < x_tab[i+1]/x_tab[i] (or u < x_tab[i+1]/x_tab[i])
249248
if test_x < x_tab[i + 1] {

branches/auto/src/libtest/stats.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use std::hash::Hash;
1717
use std::io;
1818
use std::mem;
1919
use std::num::Zero;
20-
use std::num;
2120

2221
fn local_cmp<T:Float>(x: T, y: T) -> Ordering {
2322
// arbitrarily decide that NaNs are larger than everything.
@@ -166,7 +165,6 @@ impl<T: FloatMath + FromPrimitive> Summary<T> {
166165
}
167166

168167
impl<'a, T: FloatMath + FromPrimitive> Stats<T> for &'a [T] {
169-
170168
// FIXME #11059 handle NaN, inf and overflow
171169
fn sum(self) -> T {
172170
let mut partials = vec![];
@@ -176,8 +174,8 @@ impl<'a, T: FloatMath + FromPrimitive> Stats<T> for &'a [T] {
176174
// This inner loop applies `hi`/`lo` summation to each
177175
// partial so that the list of partial sums remains exact.
178176
for i in range(0, partials.len()) {
179-
let mut y = partials[i];
180-
if num::abs(x) < num::abs(y) {
177+
let mut y: T = partials[i];
178+
if x.abs() < y.abs() {
181179
mem::swap(&mut x, &mut y);
182180
}
183181
// Rounded `x+y` is stored in `hi` with round-off stored in
@@ -249,7 +247,7 @@ impl<'a, T: FloatMath + FromPrimitive> Stats<T> for &'a [T] {
249247

250248
fn median_abs_dev(self) -> T {
251249
let med = self.median();
252-
let abs_devs: Vec<T> = self.iter().map(|&v| num::abs(med - v)).collect();
250+
let abs_devs: Vec<T> = self.iter().map(|&v| (med - v).abs()).collect();
253251
// This constant is derived by smarter statistics brains than me, but it is
254252
// consistent with how R and other packages treat the MAD.
255253
let number = FromPrimitive::from_f64(1.4826).unwrap();

branches/auto/src/libtime/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ extern crate libc;
3030
use std::fmt::Show;
3131
use std::fmt;
3232
use std::io::BufReader;
33-
use std::num;
3433
use std::string::String;
3534
use std::time::Duration;
3635

@@ -757,7 +756,7 @@ impl<'a> fmt::Show for TmFmt<'a> {
757756
'Z' => if tm.tm_gmtoff == 0_i32 { "GMT"} else { "" }, // FIXME (#2350): support locale
758757
'z' => {
759758
let sign = if tm.tm_gmtoff > 0_i32 { '+' } else { '-' };
760-
let mut m = num::abs(tm.tm_gmtoff) / 60_i32;
759+
let mut m = tm.tm_gmtoff.abs() / 60_i32;
761760
let h = m / 60_i32;
762761
m -= h * 60_i32;
763762
return write!(fmt, "{}{:02d}{:02d}", sign, h, m);
@@ -799,7 +798,7 @@ impl<'a> fmt::Show for TmFmt<'a> {
799798
format: FmtStr("%Y-%m-%dT%H:%M:%S"),
800799
};
801800
let sign = if self.tm.tm_gmtoff > 0_i32 { '+' } else { '-' };
802-
let mut m = num::abs(self.tm.tm_gmtoff) / 60_i32;
801+
let mut m = self.tm.tm_gmtoff.abs() / 60_i32;
803802
let h = m / 60_i32;
804803
m -= h * 60_i32;
805804
write!(fmt, "{}{}{:02d}:{:02d}", s, sign, h as int, m as int)

branches/auto/src/test/run-pass/trait-inheritance-self-in-supertype.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
// Test for issue #4183: use of Self in supertraits.
1212

13-
use std::num;
14-
1513
pub static FUZZY_EPSILON: f64 = 0.1;
1614

1715
pub trait FuzzyEq<Eps> {
@@ -29,7 +27,7 @@ impl FuzzyEq<f32> for f32 {
2927
}
3028

3129
fn fuzzy_eq_eps(&self, other: &f32, epsilon: &f32) -> bool {
32-
num::abs(*self - *other) < *epsilon
30+
(*self - *other).abs() < *epsilon
3331
}
3432
}
3533

@@ -43,7 +41,7 @@ impl FuzzyEq<f64> for f64 {
4341
}
4442

4543
fn fuzzy_eq_eps(&self, other: &f64, epsilon: &f64) -> bool {
46-
num::abs(*self - *other) < *epsilon
44+
(*self - *other).abs() < *epsilon
4745
}
4846
}
4947

branches/auto/src/test/run-pass/utf8_idents.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@
1313

1414
#![feature(non_ascii_idents)]
1515

16-
use std::num;
17-
1816
pub fn main() {
1917
let ε = 0.00001f64;
2018
let Π = 3.14f64;
2119
let लंच = Π * Π + 1.54;
22-
assert!(num::abs((लंच - 1.54) - (Π * Π)) < ε);
20+
assert!(((लंच - 1.54) - (Π * Π)).abs() < ε);
2321
assert_eq!(საჭმელად_გემრიელი_სადილი(), 0);
2422
}
2523

0 commit comments

Comments
 (0)