diff options
| author | Alexis <a.beingessner@gmail.com> | 2015-02-20 01:18:12 -0500 |
|---|---|---|
| committer | Alexis <a.beingessner@gmail.com> | 2015-02-20 19:55:00 -0500 |
| commit | ac7d964dcf62f4c6104ae8d6bf3713f697215769 (patch) | |
| tree | 678eadeb55d6f5c919bbe926e23a36e14f902a71 | |
| parent | 97aa34046ffec7be1e3e4f383f205344ed67da6d (diff) | |
| download | rust-ac7d964dcf62f4c6104ae8d6bf3713f697215769.tar.gz rust-ac7d964dcf62f4c6104ae8d6bf3713f697215769.zip | |
make int/uint modules just re-exports
| -rw-r--r-- | src/libstd/lib.rs | 4 | ||||
| -rw-r--r-- | src/libstd/num/int.rs | 22 | ||||
| -rw-r--r-- | src/libstd/num/mod.rs | 210 | ||||
| -rw-r--r-- | src/libstd/num/uint.rs | 22 |
4 files changed, 107 insertions, 151 deletions
diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 7ce545bbcf0..4b6e9cf76f9 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -218,15 +218,15 @@ mod int_macros; #[macro_use] mod uint_macros; -#[path = "num/int.rs"] pub mod int; #[path = "num/isize.rs"] pub mod isize; +pub use isize as int; #[path = "num/i8.rs"] pub mod i8; #[path = "num/i16.rs"] pub mod i16; #[path = "num/i32.rs"] pub mod i32; #[path = "num/i64.rs"] pub mod i64; -#[path = "num/uint.rs"] pub mod uint; #[path = "num/usize.rs"] pub mod usize; +pub use usize as uint; #[path = "num/u8.rs"] pub mod u8; #[path = "num/u16.rs"] pub mod u16; #[path = "num/u32.rs"] pub mod u32; diff --git a/src/libstd/num/int.rs b/src/libstd/num/int.rs deleted file mode 100644 index 669952eee39..00000000000 --- a/src/libstd/num/int.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Deprecated: replaced by `isize`. -//! -//! The rollout of the new type will gradually take place over the -//! alpha cycle along with the development of clearer conventions -//! around integer types. - -#![unstable(feature = "std_misc")] -#![deprecated(since = "1.0.0", reason = "replaced by isize")] - -pub use core::int::{BITS, BYTES, MIN, MAX}; - -int_module! { int } diff --git a/src/libstd/num/mod.rs b/src/libstd/num/mod.rs index c94c1649833..968adfafeab 100644 --- a/src/libstd/num/mod.rs +++ b/src/libstd/num/mod.rs @@ -11,7 +11,7 @@ //! Numeric traits and functions for generic mathematics //! //! These are implemented for the primitive numeric types in `std::{u8, u16, -//! u32, u64, uint, i8, i16, i32, i64, int, f32, f64}`. +//! u32, u64, usize, i8, i16, i32, i64, isize, f32, f64}`. #![stable(feature = "rust1", since = "1.0.0")] #![allow(missing_docs)] @@ -146,12 +146,12 @@ pub trait Float #[deprecated(since = "1.0.0", reason = "use `std::f32::MANTISSA_DIGITS` or \ `std::f64::MANTISSA_DIGITS` as appropriate")] - fn mantissa_digits(unused_self: Option<Self>) -> uint; + fn mantissa_digits(unused_self: Option<Self>) -> usize; /// Deprecated: use `std::f32::DIGITS` or `std::f64::DIGITS` instead. #[unstable(feature = "std_misc")] #[deprecated(since = "1.0.0", reason = "use `std::f32::DIGITS` or `std::f64::DIGITS` as appropriate")] - fn digits(unused_self: Option<Self>) -> uint; + fn digits(unused_self: Option<Self>) -> usize; /// Deprecated: use `std::f32::EPSILON` or `std::f64::EPSILON` instead. #[unstable(feature = "std_misc")] #[deprecated(since = "1.0.0", @@ -161,22 +161,22 @@ pub trait Float #[unstable(feature = "std_misc")] #[deprecated(since = "1.0.0", reason = "use `std::f32::MIN_EXP` or `std::f64::MIN_EXP` as appropriate")] - fn min_exp(unused_self: Option<Self>) -> int; + fn min_exp(unused_self: Option<Self>) -> isize; /// Deprecated: use `std::f32::MAX_EXP` or `std::f64::MAX_EXP` instead. #[unstable(feature = "std_misc")] #[deprecated(since = "1.0.0", reason = "use `std::f32::MAX_EXP` or `std::f64::MAX_EXP` as appropriate")] - fn max_exp(unused_self: Option<Self>) -> int; + fn max_exp(unused_self: Option<Self>) -> isize; /// Deprecated: use `std::f32::MIN_10_EXP` or `std::f64::MIN_10_EXP` instead. #[unstable(feature = "std_misc")] #[deprecated(since = "1.0.0", reason = "use `std::f32::MIN_10_EXP` or `std::f64::MIN_10_EXP` as appropriate")] - fn min_10_exp(unused_self: Option<Self>) -> int; + fn min_10_exp(unused_self: Option<Self>) -> isize; /// Deprecated: use `std::f32::MAX_10_EXP` or `std::f64::MAX_10_EXP` instead. #[unstable(feature = "std_misc")] #[deprecated(since = "1.0.0", reason = "use `std::f32::MAX_10_EXP` or `std::f64::MAX_10_EXP` as appropriate")] - fn max_10_exp(unused_self: Option<Self>) -> int; + fn max_10_exp(unused_self: Option<Self>) -> isize; /// Returns the smallest finite value that this type can represent. /// @@ -698,7 +698,7 @@ pub trait Float /// ``` #[unstable(feature = "std_misc", reason = "pending integer conventions")] - fn ldexp(x: Self, exp: int) -> Self; + fn ldexp(x: Self, exp: isize) -> Self; /// Breaks the number into a normalized fraction and a base-2 exponent, /// satisfying: /// @@ -720,7 +720,7 @@ pub trait Float /// ``` #[unstable(feature = "std_misc", reason = "pending integer conventions")] - fn frexp(self) -> (Self, int); + fn frexp(self) -> (Self, isize); /// Returns the next representable floating-point value in the direction of /// `other`. /// @@ -1112,12 +1112,12 @@ mod tests { use i16; use i32; use i64; - use int; + use isize; use u8; use u16; use u32; use u64; - use uint; + use usize; macro_rules! test_cast_20 { ($_20:expr) => ({ @@ -1179,25 +1179,25 @@ mod tests { #[test] fn test_cast_range_int_min() { - assert_eq!(int::MIN.to_int(), Some(int::MIN as int)); - assert_eq!(int::MIN.to_i8(), None); - assert_eq!(int::MIN.to_i16(), None); - // int::MIN.to_i32() is word-size specific - assert_eq!(int::MIN.to_i64(), Some(int::MIN as i64)); - assert_eq!(int::MIN.to_uint(), None); - assert_eq!(int::MIN.to_u8(), None); - assert_eq!(int::MIN.to_u16(), None); - assert_eq!(int::MIN.to_u32(), None); - assert_eq!(int::MIN.to_u64(), None); + assert_eq!(isize::MIN.to_int(), Some(isize::MIN as isize)); + assert_eq!(isize::MIN.to_i8(), None); + assert_eq!(isize::MIN.to_i16(), None); + // isize::MIN.to_i32() is word-size specific + assert_eq!(isize::MIN.to_i64(), Some(isize::MIN as i64)); + assert_eq!(isize::MIN.to_uint(), None); + assert_eq!(isize::MIN.to_u8(), None); + assert_eq!(isize::MIN.to_u16(), None); + assert_eq!(isize::MIN.to_u32(), None); + assert_eq!(isize::MIN.to_u64(), None); #[cfg(target_pointer_width = "32")] fn check_word_size() { - assert_eq!(int::MIN.to_i32(), Some(int::MIN as i32)); + assert_eq!(isize::MIN.to_i32(), Some(isize::MIN as i32)); } #[cfg(target_pointer_width = "64")] fn check_word_size() { - assert_eq!(int::MIN.to_i32(), None); + assert_eq!(isize::MIN.to_i32(), None); } check_word_size(); @@ -1205,7 +1205,7 @@ mod tests { #[test] fn test_cast_range_i8_min() { - assert_eq!(i8::MIN.to_int(), Some(i8::MIN as int)); + assert_eq!(i8::MIN.to_int(), Some(i8::MIN as isize)); assert_eq!(i8::MIN.to_i8(), Some(i8::MIN as i8)); assert_eq!(i8::MIN.to_i16(), Some(i8::MIN as i16)); assert_eq!(i8::MIN.to_i32(), Some(i8::MIN as i32)); @@ -1219,7 +1219,7 @@ mod tests { #[test] fn test_cast_range_i16_min() { - assert_eq!(i16::MIN.to_int(), Some(i16::MIN as int)); + assert_eq!(i16::MIN.to_int(), Some(i16::MIN as isize)); assert_eq!(i16::MIN.to_i8(), None); assert_eq!(i16::MIN.to_i16(), Some(i16::MIN as i16)); assert_eq!(i16::MIN.to_i32(), Some(i16::MIN as i32)); @@ -1233,7 +1233,7 @@ mod tests { #[test] fn test_cast_range_i32_min() { - assert_eq!(i32::MIN.to_int(), Some(i32::MIN as int)); + assert_eq!(i32::MIN.to_int(), Some(i32::MIN as isize)); assert_eq!(i32::MIN.to_i8(), None); assert_eq!(i32::MIN.to_i16(), None); assert_eq!(i32::MIN.to_i32(), Some(i32::MIN as i32)); @@ -1265,7 +1265,7 @@ mod tests { #[cfg(target_pointer_width = "64")] fn check_word_size() { - assert_eq!(i64::MIN.to_int(), Some(i64::MIN as int)); + assert_eq!(i64::MIN.to_int(), Some(i64::MIN as isize)); } check_word_size(); @@ -1273,26 +1273,26 @@ mod tests { #[test] fn test_cast_range_int_max() { - assert_eq!(int::MAX.to_int(), Some(int::MAX as int)); - assert_eq!(int::MAX.to_i8(), None); - assert_eq!(int::MAX.to_i16(), None); - // int::MAX.to_i32() is word-size specific - assert_eq!(int::MAX.to_i64(), Some(int::MAX as i64)); - assert_eq!(int::MAX.to_u8(), None); - assert_eq!(int::MAX.to_u16(), None); - // int::MAX.to_u32() is word-size specific - assert_eq!(int::MAX.to_u64(), Some(int::MAX as u64)); + assert_eq!(isize::MAX.to_int(), Some(isize::MAX as isize)); + assert_eq!(isize::MAX.to_i8(), None); + assert_eq!(isize::MAX.to_i16(), None); + // isize::MAX.to_i32() is word-size specific + assert_eq!(isize::MAX.to_i64(), Some(isize::MAX as i64)); + assert_eq!(isize::MAX.to_u8(), None); + assert_eq!(isize::MAX.to_u16(), None); + // isize::MAX.to_u32() is word-size specific + assert_eq!(isize::MAX.to_u64(), Some(isize::MAX as u64)); #[cfg(target_pointer_width = "32")] fn check_word_size() { - assert_eq!(int::MAX.to_i32(), Some(int::MAX as i32)); - assert_eq!(int::MAX.to_u32(), Some(int::MAX as u32)); + assert_eq!(isize::MAX.to_i32(), Some(isize::MAX as i32)); + assert_eq!(isize::MAX.to_u32(), Some(isize::MAX as u32)); } #[cfg(target_pointer_width = "64")] fn check_word_size() { - assert_eq!(int::MAX.to_i32(), None); - assert_eq!(int::MAX.to_u32(), None); + assert_eq!(isize::MAX.to_i32(), None); + assert_eq!(isize::MAX.to_u32(), None); } check_word_size(); @@ -1300,12 +1300,12 @@ mod tests { #[test] fn test_cast_range_i8_max() { - assert_eq!(i8::MAX.to_int(), Some(i8::MAX as int)); + assert_eq!(i8::MAX.to_int(), Some(i8::MAX as isize)); assert_eq!(i8::MAX.to_i8(), Some(i8::MAX as i8)); assert_eq!(i8::MAX.to_i16(), Some(i8::MAX as i16)); assert_eq!(i8::MAX.to_i32(), Some(i8::MAX as i32)); assert_eq!(i8::MAX.to_i64(), Some(i8::MAX as i64)); - assert_eq!(i8::MAX.to_uint(), Some(i8::MAX as uint)); + assert_eq!(i8::MAX.to_uint(), Some(i8::MAX as usize)); assert_eq!(i8::MAX.to_u8(), Some(i8::MAX as u8)); assert_eq!(i8::MAX.to_u16(), Some(i8::MAX as u16)); assert_eq!(i8::MAX.to_u32(), Some(i8::MAX as u32)); @@ -1314,12 +1314,12 @@ mod tests { #[test] fn test_cast_range_i16_max() { - assert_eq!(i16::MAX.to_int(), Some(i16::MAX as int)); + assert_eq!(i16::MAX.to_int(), Some(i16::MAX as isize)); assert_eq!(i16::MAX.to_i8(), None); assert_eq!(i16::MAX.to_i16(), Some(i16::MAX as i16)); assert_eq!(i16::MAX.to_i32(), Some(i16::MAX as i32)); assert_eq!(i16::MAX.to_i64(), Some(i16::MAX as i64)); - assert_eq!(i16::MAX.to_uint(), Some(i16::MAX as uint)); + assert_eq!(i16::MAX.to_uint(), Some(i16::MAX as usize)); assert_eq!(i16::MAX.to_u8(), None); assert_eq!(i16::MAX.to_u16(), Some(i16::MAX as u16)); assert_eq!(i16::MAX.to_u32(), Some(i16::MAX as u32)); @@ -1328,12 +1328,12 @@ mod tests { #[test] fn test_cast_range_i32_max() { - assert_eq!(i32::MAX.to_int(), Some(i32::MAX as int)); + assert_eq!(i32::MAX.to_int(), Some(i32::MAX as isize)); assert_eq!(i32::MAX.to_i8(), None); assert_eq!(i32::MAX.to_i16(), None); assert_eq!(i32::MAX.to_i32(), Some(i32::MAX as i32)); assert_eq!(i32::MAX.to_i64(), Some(i32::MAX as i64)); - assert_eq!(i32::MAX.to_uint(), Some(i32::MAX as uint)); + assert_eq!(i32::MAX.to_uint(), Some(i32::MAX as usize)); assert_eq!(i32::MAX.to_u8(), None); assert_eq!(i32::MAX.to_u16(), None); assert_eq!(i32::MAX.to_u32(), Some(i32::MAX as u32)); @@ -1361,8 +1361,8 @@ mod tests { #[cfg(target_pointer_width = "64")] fn check_word_size() { - assert_eq!(i64::MAX.to_int(), Some(i64::MAX as int)); - assert_eq!(i64::MAX.to_uint(), Some(i64::MAX as uint)); + assert_eq!(i64::MAX.to_int(), Some(i64::MAX as isize)); + assert_eq!(i64::MAX.to_uint(), Some(i64::MAX as usize)); } check_word_size(); @@ -1370,26 +1370,26 @@ mod tests { #[test] fn test_cast_range_uint_min() { - assert_eq!(uint::MIN.to_int(), Some(uint::MIN as int)); - assert_eq!(uint::MIN.to_i8(), Some(uint::MIN as i8)); - assert_eq!(uint::MIN.to_i16(), Some(uint::MIN as i16)); - assert_eq!(uint::MIN.to_i32(), Some(uint::MIN as i32)); - assert_eq!(uint::MIN.to_i64(), Some(uint::MIN as i64)); - assert_eq!(uint::MIN.to_uint(), Some(uint::MIN as uint)); - assert_eq!(uint::MIN.to_u8(), Some(uint::MIN as u8)); - assert_eq!(uint::MIN.to_u16(), Some(uint::MIN as u16)); - assert_eq!(uint::MIN.to_u32(), Some(uint::MIN as u32)); - assert_eq!(uint::MIN.to_u64(), Some(uint::MIN as u64)); + assert_eq!(usize::MIN.to_int(), Some(usize::MIN as isize)); + assert_eq!(usize::MIN.to_i8(), Some(usize::MIN as i8)); + assert_eq!(usize::MIN.to_i16(), Some(usize::MIN as i16)); + assert_eq!(usize::MIN.to_i32(), Some(usize::MIN as i32)); + assert_eq!(usize::MIN.to_i64(), Some(usize::MIN as i64)); + assert_eq!(usize::MIN.to_uint(), Some(usize::MIN as usize)); + assert_eq!(usize::MIN.to_u8(), Some(usize::MIN as u8)); + assert_eq!(usize::MIN.to_u16(), Some(usize::MIN as u16)); + assert_eq!(usize::MIN.to_u32(), Some(usize::MIN as u32)); + assert_eq!(usize::MIN.to_u64(), Some(usize::MIN as u64)); } #[test] fn test_cast_range_u8_min() { - assert_eq!(u8::MIN.to_int(), Some(u8::MIN as int)); + assert_eq!(u8::MIN.to_int(), Some(u8::MIN as isize)); assert_eq!(u8::MIN.to_i8(), Some(u8::MIN as i8)); assert_eq!(u8::MIN.to_i16(), Some(u8::MIN as i16)); assert_eq!(u8::MIN.to_i32(), Some(u8::MIN as i32)); assert_eq!(u8::MIN.to_i64(), Some(u8::MIN as i64)); - assert_eq!(u8::MIN.to_uint(), Some(u8::MIN as uint)); + assert_eq!(u8::MIN.to_uint(), Some(u8::MIN as usize)); assert_eq!(u8::MIN.to_u8(), Some(u8::MIN as u8)); assert_eq!(u8::MIN.to_u16(), Some(u8::MIN as u16)); assert_eq!(u8::MIN.to_u32(), Some(u8::MIN as u32)); @@ -1398,12 +1398,12 @@ mod tests { #[test] fn test_cast_range_u16_min() { - assert_eq!(u16::MIN.to_int(), Some(u16::MIN as int)); + assert_eq!(u16::MIN.to_int(), Some(u16::MIN as isize)); assert_eq!(u16::MIN.to_i8(), Some(u16::MIN as i8)); assert_eq!(u16::MIN.to_i16(), Some(u16::MIN as i16)); assert_eq!(u16::MIN.to_i32(), Some(u16::MIN as i32)); assert_eq!(u16::MIN.to_i64(), Some(u16::MIN as i64)); - assert_eq!(u16::MIN.to_uint(), Some(u16::MIN as uint)); + assert_eq!(u16::MIN.to_uint(), Some(u16::MIN as usize)); assert_eq!(u16::MIN.to_u8(), Some(u16::MIN as u8)); assert_eq!(u16::MIN.to_u16(), Some(u16::MIN as u16)); assert_eq!(u16::MIN.to_u32(), Some(u16::MIN as u32)); @@ -1412,12 +1412,12 @@ mod tests { #[test] fn test_cast_range_u32_min() { - assert_eq!(u32::MIN.to_int(), Some(u32::MIN as int)); + assert_eq!(u32::MIN.to_int(), Some(u32::MIN as isize)); assert_eq!(u32::MIN.to_i8(), Some(u32::MIN as i8)); assert_eq!(u32::MIN.to_i16(), Some(u32::MIN as i16)); assert_eq!(u32::MIN.to_i32(), Some(u32::MIN as i32)); assert_eq!(u32::MIN.to_i64(), Some(u32::MIN as i64)); - assert_eq!(u32::MIN.to_uint(), Some(u32::MIN as uint)); + assert_eq!(u32::MIN.to_uint(), Some(u32::MIN as usize)); assert_eq!(u32::MIN.to_u8(), Some(u32::MIN as u8)); assert_eq!(u32::MIN.to_u16(), Some(u32::MIN as u16)); assert_eq!(u32::MIN.to_u32(), Some(u32::MIN as u32)); @@ -1426,12 +1426,12 @@ mod tests { #[test] fn test_cast_range_u64_min() { - assert_eq!(u64::MIN.to_int(), Some(u64::MIN as int)); + assert_eq!(u64::MIN.to_int(), Some(u64::MIN as isize)); assert_eq!(u64::MIN.to_i8(), Some(u64::MIN as i8)); assert_eq!(u64::MIN.to_i16(), Some(u64::MIN as i16)); assert_eq!(u64::MIN.to_i32(), Some(u64::MIN as i32)); assert_eq!(u64::MIN.to_i64(), Some(u64::MIN as i64)); - assert_eq!(u64::MIN.to_uint(), Some(u64::MIN as uint)); + assert_eq!(u64::MIN.to_uint(), Some(u64::MIN as usize)); assert_eq!(u64::MIN.to_u8(), Some(u64::MIN as u8)); assert_eq!(u64::MIN.to_u16(), Some(u64::MIN as u16)); assert_eq!(u64::MIN.to_u32(), Some(u64::MIN as u32)); @@ -1440,26 +1440,26 @@ mod tests { #[test] fn test_cast_range_uint_max() { - assert_eq!(uint::MAX.to_int(), None); - assert_eq!(uint::MAX.to_i8(), None); - assert_eq!(uint::MAX.to_i16(), None); - assert_eq!(uint::MAX.to_i32(), None); - // uint::MAX.to_i64() is word-size specific - assert_eq!(uint::MAX.to_u8(), None); - assert_eq!(uint::MAX.to_u16(), None); - // uint::MAX.to_u32() is word-size specific - assert_eq!(uint::MAX.to_u64(), Some(uint::MAX as u64)); + assert_eq!(usize::MAX.to_int(), None); + assert_eq!(usize::MAX.to_i8(), None); + assert_eq!(usize::MAX.to_i16(), None); + assert_eq!(usize::MAX.to_i32(), None); + // usize::MAX.to_i64() is word-size specific + assert_eq!(usize::MAX.to_u8(), None); + assert_eq!(usize::MAX.to_u16(), None); + // usize::MAX.to_u32() is word-size specific + assert_eq!(usize::MAX.to_u64(), Some(usize::MAX as u64)); #[cfg(target_pointer_width = "32")] fn check_word_size() { - assert_eq!(uint::MAX.to_u32(), Some(uint::MAX as u32)); - assert_eq!(uint::MAX.to_i64(), Some(uint::MAX as i64)); + assert_eq!(usize::MAX.to_u32(), Some(usize::MAX as u32)); + assert_eq!(usize::MAX.to_i64(), Some(usize::MAX as i64)); } #[cfg(target_pointer_width = "64")] fn check_word_size() { - assert_eq!(uint::MAX.to_u32(), None); - assert_eq!(uint::MAX.to_i64(), None); + assert_eq!(usize::MAX.to_u32(), None); + assert_eq!(usize::MAX.to_i64(), None); } check_word_size(); @@ -1467,12 +1467,12 @@ mod tests { #[test] fn test_cast_range_u8_max() { - assert_eq!(u8::MAX.to_int(), Some(u8::MAX as int)); + assert_eq!(u8::MAX.to_int(), Some(u8::MAX as isize)); assert_eq!(u8::MAX.to_i8(), None); assert_eq!(u8::MAX.to_i16(), Some(u8::MAX as i16)); assert_eq!(u8::MAX.to_i32(), Some(u8::MAX as i32)); assert_eq!(u8::MAX.to_i64(), Some(u8::MAX as i64)); - assert_eq!(u8::MAX.to_uint(), Some(u8::MAX as uint)); + assert_eq!(u8::MAX.to_uint(), Some(u8::MAX as usize)); assert_eq!(u8::MAX.to_u8(), Some(u8::MAX as u8)); assert_eq!(u8::MAX.to_u16(), Some(u8::MAX as u16)); assert_eq!(u8::MAX.to_u32(), Some(u8::MAX as u32)); @@ -1481,12 +1481,12 @@ mod tests { #[test] fn test_cast_range_u16_max() { - assert_eq!(u16::MAX.to_int(), Some(u16::MAX as int)); + assert_eq!(u16::MAX.to_int(), Some(u16::MAX as isize)); assert_eq!(u16::MAX.to_i8(), None); assert_eq!(u16::MAX.to_i16(), None); assert_eq!(u16::MAX.to_i32(), Some(u16::MAX as i32)); assert_eq!(u16::MAX.to_i64(), Some(u16::MAX as i64)); - assert_eq!(u16::MAX.to_uint(), Some(u16::MAX as uint)); + assert_eq!(u16::MAX.to_uint(), Some(u16::MAX as usize)); assert_eq!(u16::MAX.to_u8(), None); assert_eq!(u16::MAX.to_u16(), Some(u16::MAX as u16)); assert_eq!(u16::MAX.to_u32(), Some(u16::MAX as u32)); @@ -1500,7 +1500,7 @@ mod tests { assert_eq!(u32::MAX.to_i16(), None); assert_eq!(u32::MAX.to_i32(), None); assert_eq!(u32::MAX.to_i64(), Some(u32::MAX as i64)); - assert_eq!(u32::MAX.to_uint(), Some(u32::MAX as uint)); + assert_eq!(u32::MAX.to_uint(), Some(u32::MAX as usize)); assert_eq!(u32::MAX.to_u8(), None); assert_eq!(u32::MAX.to_u16(), None); assert_eq!(u32::MAX.to_u32(), Some(u32::MAX as u32)); @@ -1513,7 +1513,7 @@ mod tests { #[cfg(target_pointer_width = "64")] fn check_word_size() { - assert_eq!(u32::MAX.to_int(), Some(u32::MAX as int)); + assert_eq!(u32::MAX.to_int(), Some(u32::MAX as isize)); } check_word_size(); @@ -1539,7 +1539,7 @@ mod tests { #[cfg(target_pointer_width = "64")] fn check_word_size() { - assert_eq!(u64::MAX.to_uint(), Some(u64::MAX as uint)); + assert_eq!(u64::MAX.to_uint(), Some(u64::MAX as usize)); } check_word_size(); @@ -1547,7 +1547,7 @@ mod tests { #[test] fn test_saturating_add_uint() { - use uint::MAX; + use usize::MAX; assert_eq!(3_usize.saturating_add(5_usize), 8_usize); assert_eq!(3_usize.saturating_add(MAX-1), MAX); assert_eq!(MAX.saturating_add(MAX), MAX); @@ -1556,7 +1556,7 @@ mod tests { #[test] fn test_saturating_sub_uint() { - use uint::MAX; + use usize::MAX; assert_eq!(5_usize.saturating_sub(3_usize), 2_usize); assert_eq!(3_usize.saturating_sub(5_usize), 0_usize); assert_eq!(0_usize.saturating_sub(1_usize), 0_usize); @@ -1565,7 +1565,7 @@ mod tests { #[test] fn test_saturating_add_int() { - use int::{MIN,MAX}; + use isize::{MIN,MAX}; assert_eq!(3.saturating_add(5), 8); assert_eq!(3.saturating_add(MAX-1), MAX); assert_eq!(MAX.saturating_add(MAX), MAX); @@ -1577,7 +1577,7 @@ mod tests { #[test] fn test_saturating_sub_int() { - use int::{MIN,MAX}; + use isize::{MIN,MAX}; assert_eq!(3.saturating_sub(5), -2); assert_eq!(MIN.saturating_sub(1), MIN); assert_eq!((-2).saturating_sub(MAX), MIN); @@ -1589,13 +1589,13 @@ mod tests { #[test] fn test_checked_add() { - let five_less = uint::MAX - 5; - assert_eq!(five_less.checked_add(0), Some(uint::MAX - 5)); - assert_eq!(five_less.checked_add(1), Some(uint::MAX - 4)); - assert_eq!(five_less.checked_add(2), Some(uint::MAX - 3)); - assert_eq!(five_less.checked_add(3), Some(uint::MAX - 2)); - assert_eq!(five_less.checked_add(4), Some(uint::MAX - 1)); - assert_eq!(five_less.checked_add(5), Some(uint::MAX)); + let five_less = usize::MAX - 5; + assert_eq!(five_less.checked_add(0), Some(usize::MAX - 5)); + assert_eq!(five_less.checked_add(1), Some(usize::MAX - 4)); + assert_eq!(five_less.checked_add(2), Some(usize::MAX - 3)); + assert_eq!(five_less.checked_add(3), Some(usize::MAX - 2)); + assert_eq!(five_less.checked_add(4), Some(usize::MAX - 1)); + assert_eq!(five_less.checked_add(5), Some(usize::MAX)); assert_eq!(five_less.checked_add(6), None); assert_eq!(five_less.checked_add(7), None); } @@ -1614,7 +1614,7 @@ mod tests { #[test] fn test_checked_mul() { - let third = uint::MAX / 3; + let third = usize::MAX / 3; assert_eq!(third.checked_mul(0), Some(0)); assert_eq!(third.checked_mul(1), Some(third)); assert_eq!(third.checked_mul(2), Some(third * 2)); @@ -1641,7 +1641,7 @@ mod tests { test_is_power_of_two!{ test_is_power_of_two_u16, u16 } test_is_power_of_two!{ test_is_power_of_two_u32, u32 } test_is_power_of_two!{ test_is_power_of_two_u64, u64 } - test_is_power_of_two!{ test_is_power_of_two_uint, uint } + test_is_power_of_two!{ test_is_power_of_two_uint, usize } macro_rules! test_next_power_of_two { ($test_name:ident, $T:ident) => ( @@ -1661,7 +1661,7 @@ mod tests { test_next_power_of_two! { test_next_power_of_two_u16, u16 } test_next_power_of_two! { test_next_power_of_two_u32, u32 } test_next_power_of_two! { test_next_power_of_two_u64, u64 } - test_next_power_of_two! { test_next_power_of_two_uint, uint } + test_next_power_of_two! { test_next_power_of_two_uint, usize } macro_rules! test_checked_next_power_of_two { ($test_name:ident, $T:ident) => ( @@ -1684,10 +1684,10 @@ mod tests { test_checked_next_power_of_two! { test_checked_next_power_of_two_u16, u16 } test_checked_next_power_of_two! { test_checked_next_power_of_two_u32, u32 } test_checked_next_power_of_two! { test_checked_next_power_of_two_u64, u64 } - test_checked_next_power_of_two! { test_checked_next_power_of_two_uint, uint } + test_checked_next_power_of_two! { test_checked_next_power_of_two_uint, usize } #[derive(PartialEq, Debug)] - struct Value { x: int } + struct Value { x: isize } impl ToPrimitive for Value { fn to_i64(&self) -> Option<i64> { self.x.to_i64() } @@ -1695,8 +1695,8 @@ mod tests { } impl FromPrimitive for Value { - fn from_i64(n: i64) -> Option<Value> { Some(Value { x: n as int }) } - fn from_u64(n: u64) -> Option<Value> { Some(Value { x: n as int }) } + fn from_i64(n: i64) -> Option<Value> { Some(Value { x: n as isize }) } + fn from_u64(n: u64) -> Option<Value> { Some(Value { x: n as isize }) } } #[test] @@ -1734,7 +1734,7 @@ mod tests { #[test] fn test_pow() { - fn naive_pow<T: Int>(base: T, exp: uint) -> T { + fn naive_pow<T: Int>(base: T, exp: usize) -> T { let one: T = Int::one(); (0..exp).fold(one, |acc, _| acc * base) } diff --git a/src/libstd/num/uint.rs b/src/libstd/num/uint.rs deleted file mode 100644 index c7b491381f3..00000000000 --- a/src/libstd/num/uint.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Deprecated: replaced by `usize`. -//! -//! The rollout of the new type will gradually take place over the -//! alpha cycle along with the development of clearer conventions -//! around integer types. - -#![unstable(feature = "std_misc")] -#![deprecated(since = "1.0.0", reason = "replaced by usize")] - -pub use core::uint::{BITS, BYTES, MIN, MAX}; - -uint_module! { uint } |
