diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-03-25 17:06:52 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-03-26 12:10:22 -0700 |
| commit | 43bfaa4a336095eb5697fb2df50909fd3c72ed14 (patch) | |
| tree | e10610e1ce9811c89e1291b786d7a49b63ee02d9 /src/libstd/num | |
| parent | 54f16b818b58f6d6e81891b041fc751986e75155 (diff) | |
| download | rust-43bfaa4a336095eb5697fb2df50909fd3c72ed14.tar.gz rust-43bfaa4a336095eb5697fb2df50909fd3c72ed14.zip | |
Mass rename uint/int to usize/isize
Now that support has been removed, all lingering use cases are renamed.
Diffstat (limited to 'src/libstd/num')
| -rw-r--r-- | src/libstd/num/f32.rs | 42 | ||||
| -rw-r--r-- | src/libstd/num/f64.rs | 42 | ||||
| -rw-r--r-- | src/libstd/num/strconv.rs | 52 |
3 files changed, 68 insertions, 68 deletions
diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index a4f06f14d49..dc1d53b8a39 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -91,27 +91,27 @@ impl Float for f32 { #[allow(deprecated)] #[inline] - fn mantissa_digits(unused_self: Option<f32>) -> uint { + fn mantissa_digits(unused_self: Option<f32>) -> usize { num::Float::mantissa_digits(unused_self) } #[allow(deprecated)] #[inline] - fn digits(unused_self: Option<f32>) -> uint { num::Float::digits(unused_self) } + fn digits(unused_self: Option<f32>) -> usize { num::Float::digits(unused_self) } #[allow(deprecated)] #[inline] fn epsilon() -> f32 { num::Float::epsilon() } #[allow(deprecated)] #[inline] - fn min_exp(unused_self: Option<f32>) -> int { num::Float::min_exp(unused_self) } + fn min_exp(unused_self: Option<f32>) -> isize { num::Float::min_exp(unused_self) } #[allow(deprecated)] #[inline] - fn max_exp(unused_self: Option<f32>) -> int { num::Float::max_exp(unused_self) } + fn max_exp(unused_self: Option<f32>) -> isize { num::Float::max_exp(unused_self) } #[allow(deprecated)] #[inline] - fn min_10_exp(unused_self: Option<f32>) -> int { num::Float::min_10_exp(unused_self) } + fn min_10_exp(unused_self: Option<f32>) -> isize { num::Float::min_10_exp(unused_self) } #[allow(deprecated)] #[inline] - fn max_10_exp(unused_self: Option<f32>) -> int { num::Float::max_10_exp(unused_self) } + fn max_10_exp(unused_self: Option<f32>) -> isize { num::Float::max_10_exp(unused_self) } #[allow(deprecated)] #[inline] fn min_value() -> f32 { num::Float::min_value() } @@ -201,11 +201,11 @@ impl Float for f32 { /// - `self = x * pow(2, exp)` /// - `0.5 <= abs(x) < 1.0` #[inline] - fn frexp(self) -> (f32, int) { + fn frexp(self) -> (f32, isize) { unsafe { let mut exp = 0; let x = cmath::frexpf(self, &mut exp); - (x, exp as int) + (x, exp as isize) } } @@ -476,7 +476,7 @@ impl f32 { `std::f64::MANTISSA_DIGITS` as appropriate")] #[allow(deprecated)] #[inline] - pub fn mantissa_digits(unused_self: Option<f32>) -> uint { + pub fn mantissa_digits(unused_self: Option<f32>) -> usize { num::Float::mantissa_digits(unused_self) } @@ -486,7 +486,7 @@ impl f32 { reason = "use `std::f32::DIGITS` or `std::f64::DIGITS` as appropriate")] #[allow(deprecated)] #[inline] - pub fn digits(unused_self: Option<f32>) -> uint { num::Float::digits(unused_self) } + pub fn digits(unused_self: Option<f32>) -> usize { num::Float::digits(unused_self) } /// Deprecated: use `std::f32::EPSILON` or `std::f64::EPSILON` instead. #[unstable(feature = "std_misc")] @@ -502,7 +502,7 @@ impl f32 { reason = "use `std::f32::MIN_EXP` or `std::f64::MIN_EXP` as appropriate")] #[allow(deprecated)] #[inline] - pub fn min_exp(unused_self: Option<f32>) -> int { num::Float::min_exp(unused_self) } + pub fn min_exp(unused_self: Option<f32>) -> isize { num::Float::min_exp(unused_self) } /// Deprecated: use `std::f32::MAX_EXP` or `std::f64::MAX_EXP` instead. #[unstable(feature = "std_misc")] @@ -510,7 +510,7 @@ impl f32 { reason = "use `std::f32::MAX_EXP` or `std::f64::MAX_EXP` as appropriate")] #[allow(deprecated)] #[inline] - pub fn max_exp(unused_self: Option<f32>) -> int { num::Float::max_exp(unused_self) } + pub fn max_exp(unused_self: Option<f32>) -> isize { num::Float::max_exp(unused_self) } /// Deprecated: use `std::f32::MIN_10_EXP` or `std::f64::MIN_10_EXP` instead. #[unstable(feature = "std_misc")] @@ -518,7 +518,7 @@ impl f32 { reason = "use `std::f32::MIN_10_EXP` or `std::f64::MIN_10_EXP` as appropriate")] #[allow(deprecated)] #[inline] - pub fn min_10_exp(unused_self: Option<f32>) -> int { num::Float::min_10_exp(unused_self) } + pub fn min_10_exp(unused_self: Option<f32>) -> isize { num::Float::min_10_exp(unused_self) } /// Deprecated: use `std::f32::MAX_10_EXP` or `std::f64::MAX_10_EXP` instead. #[unstable(feature = "std_misc")] @@ -526,7 +526,7 @@ impl f32 { reason = "use `std::f32::MAX_10_EXP` or `std::f64::MAX_10_EXP` as appropriate")] #[allow(deprecated)] #[inline] - pub fn max_10_exp(unused_self: Option<f32>) -> int { num::Float::max_10_exp(unused_self) } + pub fn max_10_exp(unused_self: Option<f32>) -> isize { num::Float::max_10_exp(unused_self) } /// Returns the smallest finite value that this type can represent. /// @@ -1126,7 +1126,7 @@ impl f32 { #[unstable(feature = "std_misc", reason = "pending integer conventions")] #[inline] - pub fn ldexp(x: f32, exp: int) -> f32 { + pub fn ldexp(x: f32, exp: isize) -> f32 { unsafe { cmath::ldexpf(x, exp as c_int) } } @@ -1153,11 +1153,11 @@ impl f32 { #[unstable(feature = "std_misc", reason = "pending integer conventions")] #[inline] - pub fn frexp(self) -> (f32, int) { + pub fn frexp(self) -> (f32, isize) { unsafe { let mut exp = 0; let x = cmath::frexpf(self, &mut exp); - (x, exp as int) + (x, exp as isize) } } @@ -1681,7 +1681,7 @@ pub fn to_str_radix_special(num: f32, rdx: u32) -> (String, bool) { /// * digits - The number of significant digits #[inline] #[unstable(feature = "std_misc", reason = "may be removed or relocated")] -pub fn to_str_exact(num: f32, dig: uint) -> String { +pub fn to_str_exact(num: f32, dig: usize) -> String { let (r, _) = strconv::float_to_str_common( num, 10, true, SignNeg, DigExact(dig), ExpNone, false); r @@ -1696,7 +1696,7 @@ pub fn to_str_exact(num: f32, dig: uint) -> String { /// * digits - The number of significant digits #[inline] #[unstable(feature = "std_misc", reason = "may be removed or relocated")] -pub fn to_str_digits(num: f32, dig: uint) -> String { +pub fn to_str_digits(num: f32, dig: usize) -> String { let (r, _) = strconv::float_to_str_common( num, 10, true, SignNeg, DigMax(dig), ExpNone, false); r @@ -1712,7 +1712,7 @@ pub fn to_str_digits(num: f32, dig: uint) -> String { /// * upper - Use `E` instead of `e` for the exponent sign #[inline] #[unstable(feature = "std_misc", reason = "may be removed or relocated")] -pub fn to_str_exp_exact(num: f32, dig: uint, upper: bool) -> String { +pub fn to_str_exp_exact(num: f32, dig: usize, upper: bool) -> String { let (r, _) = strconv::float_to_str_common( num, 10, true, SignNeg, DigExact(dig), ExpDec, upper); r @@ -1728,7 +1728,7 @@ pub fn to_str_exp_exact(num: f32, dig: uint, upper: bool) -> String { /// * upper - Use `E` instead of `e` for the exponent sign #[inline] #[unstable(feature = "std_misc", reason = "may be removed or relocated")] -pub fn to_str_exp_digits(num: f32, dig: uint, upper: bool) -> String { +pub fn to_str_exp_digits(num: f32, dig: usize, upper: bool) -> String { let (r, _) = strconv::float_to_str_common( num, 10, true, SignNeg, DigMax(dig), ExpDec, upper); r diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index 9306804d1f7..41ce9a2598c 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -101,27 +101,27 @@ impl Float for f64 { #[allow(deprecated)] #[inline] - fn mantissa_digits(unused_self: Option<f64>) -> uint { + fn mantissa_digits(unused_self: Option<f64>) -> usize { num::Float::mantissa_digits(unused_self) } #[allow(deprecated)] #[inline] - fn digits(unused_self: Option<f64>) -> uint { num::Float::digits(unused_self) } + fn digits(unused_self: Option<f64>) -> usize { num::Float::digits(unused_self) } #[allow(deprecated)] #[inline] fn epsilon() -> f64 { num::Float::epsilon() } #[allow(deprecated)] #[inline] - fn min_exp(unused_self: Option<f64>) -> int { num::Float::min_exp(unused_self) } + fn min_exp(unused_self: Option<f64>) -> isize { num::Float::min_exp(unused_self) } #[allow(deprecated)] #[inline] - fn max_exp(unused_self: Option<f64>) -> int { num::Float::max_exp(unused_self) } + fn max_exp(unused_self: Option<f64>) -> isize { num::Float::max_exp(unused_self) } #[allow(deprecated)] #[inline] - fn min_10_exp(unused_self: Option<f64>) -> int { num::Float::min_10_exp(unused_self) } + fn min_10_exp(unused_self: Option<f64>) -> isize { num::Float::min_10_exp(unused_self) } #[allow(deprecated)] #[inline] - fn max_10_exp(unused_self: Option<f64>) -> int { num::Float::max_10_exp(unused_self) } + fn max_10_exp(unused_self: Option<f64>) -> isize { num::Float::max_10_exp(unused_self) } #[allow(deprecated)] #[inline] fn min_value() -> f64 { num::Float::min_value() } @@ -210,11 +210,11 @@ impl Float for f64 { /// - `self = x * pow(2, exp)` /// - `0.5 <= abs(x) < 1.0` #[inline] - fn frexp(self) -> (f64, int) { + fn frexp(self) -> (f64, isize) { unsafe { let mut exp = 0; let x = cmath::frexp(self, &mut exp); - (x, exp as int) + (x, exp as isize) } } @@ -485,7 +485,7 @@ impl f64 { `std::f64::MANTISSA_DIGITS` as appropriate")] #[allow(deprecated)] #[inline] - pub fn mantissa_digits(unused_self: Option<f64>) -> uint { + pub fn mantissa_digits(unused_self: Option<f64>) -> usize { num::Float::mantissa_digits(unused_self) } @@ -495,7 +495,7 @@ impl f64 { reason = "use `std::f32::DIGITS` or `std::f64::DIGITS` as appropriate")] #[allow(deprecated)] #[inline] - pub fn digits(unused_self: Option<f64>) -> uint { num::Float::digits(unused_self) } + pub fn digits(unused_self: Option<f64>) -> usize { num::Float::digits(unused_self) } /// Deprecated: use `std::f32::EPSILON` or `std::f64::EPSILON` instead. #[unstable(feature = "std_misc")] @@ -511,7 +511,7 @@ impl f64 { reason = "use `std::f32::MIN_EXP` or `std::f64::MIN_EXP` as appropriate")] #[allow(deprecated)] #[inline] - pub fn min_exp(unused_self: Option<f64>) -> int { num::Float::min_exp(unused_self) } + pub fn min_exp(unused_self: Option<f64>) -> isize { num::Float::min_exp(unused_self) } /// Deprecated: use `std::f32::MAX_EXP` or `std::f64::MAX_EXP` instead. #[unstable(feature = "std_misc")] @@ -519,7 +519,7 @@ impl f64 { reason = "use `std::f32::MAX_EXP` or `std::f64::MAX_EXP` as appropriate")] #[allow(deprecated)] #[inline] - pub fn max_exp(unused_self: Option<f64>) -> int { num::Float::max_exp(unused_self) } + pub fn max_exp(unused_self: Option<f64>) -> isize { num::Float::max_exp(unused_self) } /// Deprecated: use `std::f32::MIN_10_EXP` or `std::f64::MIN_10_EXP` instead. #[unstable(feature = "std_misc")] @@ -527,7 +527,7 @@ impl f64 { reason = "use `std::f32::MIN_10_EXP` or `std::f64::MIN_10_EXP` as appropriate")] #[allow(deprecated)] #[inline] - pub fn min_10_exp(unused_self: Option<f64>) -> int { num::Float::min_10_exp(unused_self) } + pub fn min_10_exp(unused_self: Option<f64>) -> isize { num::Float::min_10_exp(unused_self) } /// Deprecated: use `std::f32::MAX_10_EXP` or `std::f64::MAX_10_EXP` instead. #[unstable(feature = "std_misc")] @@ -535,7 +535,7 @@ impl f64 { reason = "use `std::f32::MAX_10_EXP` or `std::f64::MAX_10_EXP` as appropriate")] #[allow(deprecated)] #[inline] - pub fn max_10_exp(unused_self: Option<f64>) -> int { num::Float::max_10_exp(unused_self) } + pub fn max_10_exp(unused_self: Option<f64>) -> isize { num::Float::max_10_exp(unused_self) } /// Returns the smallest finite value that this type can represent. /// @@ -1134,7 +1134,7 @@ impl f64 { #[unstable(feature = "std_misc", reason = "pending integer conventions")] #[inline] - pub fn ldexp(x: f64, exp: int) -> f64 { + pub fn ldexp(x: f64, exp: isize) -> f64 { unsafe { cmath::ldexp(x, exp as c_int) } } @@ -1161,11 +1161,11 @@ impl f64 { #[unstable(feature = "std_misc", reason = "pending integer conventions")] #[inline] - pub fn frexp(self) -> (f64, int) { + pub fn frexp(self) -> (f64, isize) { unsafe { let mut exp = 0; let x = cmath::frexp(self, &mut exp); - (x, exp as int) + (x, exp as isize) } } @@ -1687,7 +1687,7 @@ pub fn to_str_radix_special(num: f64, rdx: u32) -> (String, bool) { /// * digits - The number of significant digits #[inline] #[unstable(feature = "std_misc", reason = "may be removed or relocated")] -pub fn to_str_exact(num: f64, dig: uint) -> String { +pub fn to_str_exact(num: f64, dig: usize) -> String { let (r, _) = strconv::float_to_str_common( num, 10, true, SignNeg, DigExact(dig), ExpNone, false); r @@ -1702,7 +1702,7 @@ pub fn to_str_exact(num: f64, dig: uint) -> String { /// * digits - The number of significant digits #[inline] #[unstable(feature = "std_misc", reason = "may be removed or relocated")] -pub fn to_str_digits(num: f64, dig: uint) -> String { +pub fn to_str_digits(num: f64, dig: usize) -> String { let (r, _) = strconv::float_to_str_common( num, 10, true, SignNeg, DigMax(dig), ExpNone, false); r @@ -1718,7 +1718,7 @@ pub fn to_str_digits(num: f64, dig: uint) -> String { /// * upper - Use `E` instead of `e` for the exponent sign #[inline] #[unstable(feature = "std_misc", reason = "may be removed or relocated")] -pub fn to_str_exp_exact(num: f64, dig: uint, upper: bool) -> String { +pub fn to_str_exp_exact(num: f64, dig: usize, upper: bool) -> String { let (r, _) = strconv::float_to_str_common( num, 10, true, SignNeg, DigExact(dig), ExpDec, upper); r @@ -1734,7 +1734,7 @@ pub fn to_str_exp_exact(num: f64, dig: uint, upper: bool) -> String { /// * upper - Use `E` instead of `e` for the exponent sign #[inline] #[unstable(feature = "std_misc", reason = "may be removed or relocated")] -pub fn to_str_exp_digits(num: f64, dig: uint, upper: bool) -> String { +pub fn to_str_exp_digits(num: f64, dig: usize, upper: bool) -> String { let (r, _) = strconv::float_to_str_common( num, 10, true, SignNeg, DigMax(dig), ExpDec, upper); r diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs index 66826b359e6..1c1aaeb6d53 100644 --- a/src/libstd/num/strconv.rs +++ b/src/libstd/num/strconv.rs @@ -49,10 +49,10 @@ pub enum SignificantDigits { /// At most the given number of digits will be printed, truncating any /// trailing zeroes. - DigMax(uint), + DigMax(usize), /// Precisely the given number of digits will be printed. - DigExact(uint) + DigExact(usize) } /// How to emit the sign of a number. @@ -87,7 +87,7 @@ pub enum SignFormat { /// # Panics /// /// - Panics if `radix` < 2 or `radix` > 36. -fn int_to_str_bytes_common<T, F>(num: T, radix: uint, sign: SignFormat, mut f: F) where +fn int_to_str_bytes_common<T, F>(num: T, radix: usize, sign: SignFormat, mut f: F) where T: Int, F: FnMut(u8), { @@ -216,7 +216,7 @@ pub fn float_to_str_bytes_common<T: Float>( let neg = num < _0 || (negative_zero && _1 / num == Float::neg_infinity()); let mut buf = Vec::new(); - let radix_gen: T = num::cast(radix as int).unwrap(); + let radix_gen: T = num::cast(radix as isize).unwrap(); let (num, exp) = match exp_format { ExpNone => (num, 0), @@ -328,28 +328,28 @@ pub fn float_to_str_bytes_common<T: Float>( let extra_digit = ascii2value(buf.pop().unwrap()); if extra_digit >= radix / 2 { // -> need to round - let mut i: int = buf.len() as int - 1; + let mut i: isize = buf.len() as isize - 1; loop { // If reached left end of number, have to // insert additional digit: if i < 0 - || buf[i as uint] == b'-' - || buf[i as uint] == b'+' { - buf.insert((i + 1) as uint, value2ascii(1)); + || buf[i as usize] == b'-' + || buf[i as usize] == b'+' { + buf.insert((i + 1) as usize, value2ascii(1)); break; } // Skip the '.' - if buf[i as uint] == b'.' { i -= 1; continue; } + if buf[i as usize] == b'.' { i -= 1; continue; } // Either increment the digit, // or set to 0 if max and carry the 1. - let current_digit = ascii2value(buf[i as uint]); + let current_digit = ascii2value(buf[i as usize]); if current_digit < (radix - 1) { - buf[i as uint] = value2ascii(current_digit+1); + buf[i as usize] = value2ascii(current_digit+1); break; } else { - buf[i as uint] = value2ascii(0); + buf[i as usize] = value2ascii(0); i -= 1; } } @@ -461,85 +461,85 @@ mod bench { #![allow(deprecated)] // rand extern crate test; - mod uint { + mod usize { use super::test::Bencher; use rand::{weak_rng, Rng}; use std::fmt; #[inline] - fn to_string(x: uint, base: u8) { + fn to_string(x: usize, base: u8) { format!("{}", fmt::radix(x, base)); } #[bench] fn to_str_bin(b: &mut Bencher) { let mut rng = weak_rng(); - b.iter(|| { to_string(rng.gen::<uint>(), 2); }) + b.iter(|| { to_string(rng.gen::<usize>(), 2); }) } #[bench] fn to_str_oct(b: &mut Bencher) { let mut rng = weak_rng(); - b.iter(|| { to_string(rng.gen::<uint>(), 8); }) + b.iter(|| { to_string(rng.gen::<usize>(), 8); }) } #[bench] fn to_str_dec(b: &mut Bencher) { let mut rng = weak_rng(); - b.iter(|| { to_string(rng.gen::<uint>(), 10); }) + b.iter(|| { to_string(rng.gen::<usize>(), 10); }) } #[bench] fn to_str_hex(b: &mut Bencher) { let mut rng = weak_rng(); - b.iter(|| { to_string(rng.gen::<uint>(), 16); }) + b.iter(|| { to_string(rng.gen::<usize>(), 16); }) } #[bench] fn to_str_base_36(b: &mut Bencher) { let mut rng = weak_rng(); - b.iter(|| { to_string(rng.gen::<uint>(), 36); }) + b.iter(|| { to_string(rng.gen::<usize>(), 36); }) } } - mod int { + mod isize { use super::test::Bencher; use rand::{weak_rng, Rng}; use std::fmt; #[inline] - fn to_string(x: int, base: u8) { + fn to_string(x: isize, base: u8) { format!("{}", fmt::radix(x, base)); } #[bench] fn to_str_bin(b: &mut Bencher) { let mut rng = weak_rng(); - b.iter(|| { to_string(rng.gen::<int>(), 2); }) + b.iter(|| { to_string(rng.gen::<isize>(), 2); }) } #[bench] fn to_str_oct(b: &mut Bencher) { let mut rng = weak_rng(); - b.iter(|| { to_string(rng.gen::<int>(), 8); }) + b.iter(|| { to_string(rng.gen::<isize>(), 8); }) } #[bench] fn to_str_dec(b: &mut Bencher) { let mut rng = weak_rng(); - b.iter(|| { to_string(rng.gen::<int>(), 10); }) + b.iter(|| { to_string(rng.gen::<isize>(), 10); }) } #[bench] fn to_str_hex(b: &mut Bencher) { let mut rng = weak_rng(); - b.iter(|| { to_string(rng.gen::<int>(), 16); }) + b.iter(|| { to_string(rng.gen::<isize>(), 16); }) } #[bench] fn to_str_base_36(b: &mut Bencher) { let mut rng = weak_rng(); - b.iter(|| { to_string(rng.gen::<int>(), 36); }) + b.iter(|| { to_string(rng.gen::<isize>(), 36); }) } } |
