diff options
| author | Chris Wong <lambda.fairy@gmail.com> | 2014-01-25 20:37:51 +1300 |
|---|---|---|
| committer | Chris Wong <lambda.fairy@gmail.com> | 2014-01-25 21:38:25 +1300 |
| commit | 988e4f0a1c2802921375271bdc19f03650c024d2 (patch) | |
| tree | b2d2913ca7575e8e52f2cf6e7975ca2f0f148286 /src/libstd | |
| parent | de57a22b9a8c8416cace31c9bd3ec4c9a6888017 (diff) | |
| download | rust-988e4f0a1c2802921375271bdc19f03650c024d2.tar.gz rust-988e4f0a1c2802921375271bdc19f03650c024d2.zip | |
Uppercase numeric constants
The following are renamed: * `min_value` => `MIN` * `max_value` => `MAX` * `bits` => `BITS` * `bytes` => `BYTES` Fixes #10010.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/comm/mod.rs | 4 | ||||
| -rw-r--r-- | src/libstd/comm/select.rs | 6 | ||||
| -rw-r--r-- | src/libstd/io/extensions.rs | 8 | ||||
| -rw-r--r-- | src/libstd/io/mod.rs | 18 | ||||
| -rw-r--r-- | src/libstd/iter.rs | 26 | ||||
| -rw-r--r-- | src/libstd/num/int.rs | 8 | ||||
| -rw-r--r-- | src/libstd/num/int_macros.rs | 20 | ||||
| -rw-r--r-- | src/libstd/num/mod.rs | 490 | ||||
| -rw-r--r-- | src/libstd/num/uint.rs | 10 | ||||
| -rw-r--r-- | src/libstd/num/uint_macros.rs | 16 | ||||
| -rw-r--r-- | src/libstd/option.rs | 4 | ||||
| -rw-r--r-- | src/libstd/rand/rand_impls.rs | 6 | ||||
| -rw-r--r-- | src/libstd/result.rs | 4 | ||||
| -rw-r--r-- | src/libstd/rt/thread.rs | 4 | ||||
| -rw-r--r-- | src/libstd/trie.rs | 24 | ||||
| -rw-r--r-- | src/libstd/unstable/mutex.rs | 8 | ||||
| -rw-r--r-- | src/libstd/vec.rs | 6 |
17 files changed, 331 insertions, 331 deletions
diff --git a/src/libstd/comm/mod.rs b/src/libstd/comm/mod.rs index 26d67daf7c1..1281f3d6a5c 100644 --- a/src/libstd/comm/mod.rs +++ b/src/libstd/comm/mod.rs @@ -1,4 +1,4 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -367,7 +367,7 @@ struct Packet { // All implementations -- the fun part /////////////////////////////////////////////////////////////////////////////// -static DISCONNECTED: int = int::min_value; +static DISCONNECTED: int = int::MIN; static RESCHED_FREQ: int = 200; impl Packet { diff --git a/src/libstd/comm/select.rs b/src/libstd/comm/select.rs index 6a10ac56a4e..c26cea29677 100644 --- a/src/libstd/comm/select.rs +++ b/src/libstd/comm/select.rs @@ -1,4 +1,4 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -182,7 +182,7 @@ impl Select { assert!(amt > 0); let mut ready_index = amt; - let mut ready_id = uint::max_value; + let mut ready_id = uint::MAX; let mut iter = self.iter().enumerate(); // Acquire a number of blocking contexts, and block on each one @@ -242,7 +242,7 @@ impl Select { assert!(!(*packet).selecting.load(Relaxed)); } - assert!(ready_id != uint::max_value); + assert!(ready_id != uint::MAX); return ready_id; } } diff --git a/src/libstd/io/extensions.rs b/src/libstd/io/extensions.rs index e58fcc16182..6a9da944f8b 100644 --- a/src/libstd/io/extensions.rs +++ b/src/libstd/io/extensions.rs @@ -1,4 +1,4 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -401,7 +401,7 @@ mod test { #[test] fn test_read_write_le_mem() { - let uints = [0, 1, 2, 42, 10_123, 100_123_456, ::u64::max_value]; + let uints = [0, 1, 2, 42, 10_123, 100_123_456, ::u64::MAX]; let mut writer = MemWriter::new(); for i in uints.iter() { @@ -417,7 +417,7 @@ mod test { #[test] fn test_read_write_be() { - let uints = [0, 1, 2, 42, 10_123, 100_123_456, ::u64::max_value]; + let uints = [0, 1, 2, 42, 10_123, 100_123_456, ::u64::MAX]; let mut writer = MemWriter::new(); for i in uints.iter() { @@ -432,7 +432,7 @@ mod test { #[test] fn test_read_be_int_n() { - let ints = [::i32::min_value, -123456, -42, -5, 0, 1, ::i32::max_value]; + let ints = [::i32::MIN, -123456, -42, -5, 0, 1, ::i32::MAX]; let mut writer = MemWriter::new(); for i in ints.iter() { diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 30827983360..027c4f18344 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -1,4 +1,4 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -680,28 +680,28 @@ pub trait Reader { /// /// The number of bytes returned is system-dependant. fn read_le_uint(&mut self) -> uint { - self.read_le_uint_n(uint::bytes) as uint + self.read_le_uint_n(uint::BYTES) as uint } /// Reads a little-endian integer. /// /// The number of bytes returned is system-dependant. fn read_le_int(&mut self) -> int { - self.read_le_int_n(int::bytes) as int + self.read_le_int_n(int::BYTES) as int } /// Reads a big-endian unsigned integer. /// /// The number of bytes returned is system-dependant. fn read_be_uint(&mut self) -> uint { - self.read_be_uint_n(uint::bytes) as uint + self.read_be_uint_n(uint::BYTES) as uint } /// Reads a big-endian integer. /// /// The number of bytes returned is system-dependant. fn read_be_int(&mut self) -> int { - self.read_be_int_n(int::bytes) as int + self.read_be_int_n(int::BYTES) as int } /// Reads a big-endian `u64`. @@ -915,22 +915,22 @@ pub trait Writer { /// Write a little-endian uint (number of bytes depends on system). fn write_le_uint(&mut self, n: uint) { - extensions::u64_to_le_bytes(n as u64, uint::bytes, |v| self.write(v)) + extensions::u64_to_le_bytes(n as u64, uint::BYTES, |v| self.write(v)) } /// Write a little-endian int (number of bytes depends on system). fn write_le_int(&mut self, n: int) { - extensions::u64_to_le_bytes(n as u64, int::bytes, |v| self.write(v)) + extensions::u64_to_le_bytes(n as u64, int::BYTES, |v| self.write(v)) } /// Write a big-endian uint (number of bytes depends on system). fn write_be_uint(&mut self, n: uint) { - extensions::u64_to_be_bytes(n as u64, uint::bytes, |v| self.write(v)) + extensions::u64_to_be_bytes(n as u64, uint::BYTES, |v| self.write(v)) } /// Write a big-endian int (number of bytes depends on system). fn write_be_int(&mut self, n: int) { - extensions::u64_to_be_bytes(n as u64, int::bytes, |v| self.write(v)) + extensions::u64_to_be_bytes(n as u64, int::BYTES, |v| self.write(v)) } /// Write a big-endian u64 (8 bytes). diff --git a/src/libstd/iter.rs b/src/libstd/iter.rs index a65da914373..6ae45b1d732 100644 --- a/src/libstd/iter.rs +++ b/src/libstd/iter.rs @@ -681,7 +681,7 @@ pub trait DoubleEndedIterator<A>: Iterator<A> { /// of the original iterator. /// /// Note: Random access with flipped indices still only applies to the first - /// `uint::max_value` elements of the original iterator. + /// `uint::MAX` elements of the original iterator. #[inline] fn rev(self) -> Rev<Self> { Rev{iter: self} @@ -713,7 +713,7 @@ impl<'a, A, T: DoubleEndedIterator<&'a mut A>> MutableDoubleEndedIterator for T /// /// A `RandomAccessIterator` should be either infinite or a `DoubleEndedIterator`. pub trait RandomAccessIterator<A>: Iterator<A> { - /// Return the number of indexable elements. At most `std::uint::max_value` + /// Return the number of indexable elements. At most `std::uint::MAX` /// elements are indexable, even if the iterator represents a longer range. fn indexable(&self) -> uint; @@ -952,7 +952,7 @@ impl<A, T: Clone + Iterator<A>> Iterator<A> for Cycle<T> { match self.orig.size_hint() { sz @ (0, Some(0)) => sz, (0, _) => (0, None), - _ => (uint::max_value, None) + _ => (uint::MAX, None) } } } @@ -961,7 +961,7 @@ impl<A, T: Clone + RandomAccessIterator<A>> RandomAccessIterator<A> for Cycle<T> #[inline] fn indexable(&self) -> uint { if self.orig.indexable() > 0 { - uint::max_value + uint::MAX } else { 0 } @@ -1823,7 +1823,7 @@ impl<A: Add<A, A> + Clone> Iterator<A> for Counter<A> { #[inline] fn size_hint(&self) -> (uint, Option<uint>) { - (uint::max_value, None) // Too bad we can't specify an infinite lower bound + (uint::MAX, None) // Too bad we can't specify an infinite lower bound } } @@ -2049,7 +2049,7 @@ impl<A: Clone> Iterator<A> for Repeat<A> { #[inline] fn next(&mut self) -> Option<A> { self.idx(0) } #[inline] - fn size_hint(&self) -> (uint, Option<uint>) { (uint::max_value, None) } + fn size_hint(&self) -> (uint, Option<uint>) { (uint::MAX, None) } } impl<A: Clone> DoubleEndedIterator<A> for Repeat<A> { @@ -2059,7 +2059,7 @@ impl<A: Clone> DoubleEndedIterator<A> for Repeat<A> { impl<A: Clone> RandomAccessIterator<A> for Repeat<A> { #[inline] - fn indexable(&self) -> uint { uint::max_value } + fn indexable(&self) -> uint { uint::MAX } #[inline] fn idx(&self, _: uint) -> Option<A> { Some(self.element.clone()) } } @@ -2417,7 +2417,7 @@ mod tests { fn test_cycle() { let cycle_len = 3; let it = count(0u, 1).take(cycle_len).cycle(); - assert_eq!(it.size_hint(), (uint::max_value, None)); + assert_eq!(it.size_hint(), (uint::MAX, None)); for (i, x) in it.take(100).enumerate() { assert_eq!(i % cycle_len, x); } @@ -2489,19 +2489,19 @@ mod tests { let v2 = &[10, 11, 12]; let vi = v.iter(); - assert_eq!(c.size_hint(), (uint::max_value, None)); + assert_eq!(c.size_hint(), (uint::MAX, None)); assert_eq!(vi.size_hint(), (10, Some(10))); assert_eq!(c.take(5).size_hint(), (5, Some(5))); assert_eq!(c.skip(5).size_hint().second(), None); assert_eq!(c.take_while(|_| false).size_hint(), (0, None)); assert_eq!(c.skip_while(|_| false).size_hint(), (0, None)); - assert_eq!(c.enumerate().size_hint(), (uint::max_value, None)); - assert_eq!(c.chain(vi.map(|&i| i)).size_hint(), (uint::max_value, None)); + assert_eq!(c.enumerate().size_hint(), (uint::MAX, None)); + assert_eq!(c.chain(vi.map(|&i| i)).size_hint(), (uint::MAX, None)); assert_eq!(c.zip(vi).size_hint(), (10, Some(10))); assert_eq!(c.scan(0, |_,_| Some(0)).size_hint(), (0, None)); assert_eq!(c.filter(|_| false).size_hint(), (0, None)); - assert_eq!(c.map(|_| 0).size_hint(), (uint::max_value, None)); + assert_eq!(c.map(|_| 0).size_hint(), (uint::MAX, None)); assert_eq!(c.filter_map(|_| Some(0)).size_hint(), (0, None)); assert_eq!(vi.take(5).size_hint(), (5, Some(5))); @@ -2894,7 +2894,7 @@ mod tests { assert_eq!(range(0i, 100).size_hint(), (100, Some(100))); // this test is only meaningful when sizeof uint < sizeof u64 - assert_eq!(range(uint::max_value - 1, uint::max_value).size_hint(), (1, Some(1))); + assert_eq!(range(uint::MAX - 1, uint::MAX).size_hint(), (1, Some(1))); assert_eq!(range(-10i, -1).size_hint(), (9, Some(9))); assert_eq!(range(Foo, Foo).size_hint(), (0, None)); } diff --git a/src/libstd/num/int.rs b/src/libstd/num/int.rs index dbc7c67d97b..96e182adb82 100644 --- a/src/libstd/num/int.rs +++ b/src/libstd/num/int.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// 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. // @@ -123,7 +123,7 @@ impl CheckedMul for int { #[test] fn test_overflows() { - assert!((::int::max_value > 0)); - assert!((::int::min_value <= 0)); - assert!((::int::min_value + ::int::max_value + 1 == 0)); + assert!((::int::MAX > 0)); + assert!((::int::MIN <= 0)); + assert!((::int::MIN + ::int::MAX + 1 == 0)); } diff --git a/src/libstd/num/int_macros.rs b/src/libstd/num/int_macros.rs index 7102a899758..ca65ade4069 100644 --- a/src/libstd/num/int_macros.rs +++ b/src/libstd/num/int_macros.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// 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. // @@ -15,23 +15,23 @@ macro_rules! int_module (($T:ty, $bits:expr) => ( // FIXME(#11621): Should be deprecated once CTFE is implemented in favour of // calling the `mem::size_of` function. -pub static bits : uint = $bits; +pub static BITS : uint = $bits; // FIXME(#11621): Should be deprecated once CTFE is implemented in favour of // calling the `mem::size_of` function. -pub static bytes : uint = ($bits / 8); +pub static BYTES : uint = ($bits / 8); // FIXME(#11621): Should be deprecated once CTFE is implemented in favour of // calling the `Bounded::min_value` function. -pub static min_value: $T = (-1 as $T) << (bits - 1); -// FIXME(#9837): Compute min_value like this so the high bits that shouldn't exist are 0. +pub static MIN: $T = (-1 as $T) << (BITS - 1); +// FIXME(#9837): Compute MIN like this so the high bits that shouldn't exist are 0. // FIXME(#11621): Should be deprecated once CTFE is implemented in favour of // calling the `Bounded::max_value` function. -pub static max_value: $T = !min_value; +pub static MAX: $T = !MIN; impl CheckedDiv for $T { #[inline] fn checked_div(&self, v: &$T) -> Option<$T> { - if *v == 0 || (*self == min_value && *v == -1) { + if *v == 0 || (*self == MIN && *v == -1) { None } else { Some(self / *v) @@ -361,10 +361,10 @@ impl Not<$T> for $T { impl Bounded for $T { #[inline] - fn min_value() -> $T { min_value } + fn min_value() -> $T { MIN } #[inline] - fn max_value() -> $T { max_value } + fn max_value() -> $T { MAX } } impl Int for $T {} @@ -757,7 +757,7 @@ mod tests { fn test_signed_checked_div() { assert_eq!(10i.checked_div(&2), Some(5)); assert_eq!(5i.checked_div(&0), None); - assert_eq!(int::min_value.checked_div(&-1), None); + assert_eq!(int::MIN.checked_div(&-1), None); } } diff --git a/src/libstd/num/mod.rs b/src/libstd/num/mod.rs index 34dd313d442..478029b8561 100644 --- a/src/libstd/num/mod.rs +++ b/src/libstd/num/mod.rs @@ -1,4 +1,4 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// 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. // @@ -1159,25 +1159,25 @@ mod tests { #[test] fn test_cast_range_int_min() { - assert_eq!(int::min_value.to_int(), Some(int::min_value as int)); - assert_eq!(int::min_value.to_i8(), None); - assert_eq!(int::min_value.to_i16(), None); - // int::min_value.to_i32() is word-size specific - assert_eq!(int::min_value.to_i64(), Some(int::min_value as i64)); - assert_eq!(int::min_value.to_uint(), None); - assert_eq!(int::min_value.to_u8(), None); - assert_eq!(int::min_value.to_u16(), None); - assert_eq!(int::min_value.to_u32(), None); - assert_eq!(int::min_value.to_u64(), None); + 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); #[cfg(target_word_size = "32")] fn check_word_size() { - assert_eq!(int::min_value.to_i32(), Some(int::min_value as i32)); + assert_eq!(int::MIN.to_i32(), Some(int::MIN as i32)); } #[cfg(target_word_size = "64")] fn check_word_size() { - assert_eq!(int::min_value.to_i32(), None); + assert_eq!(int::MIN.to_i32(), None); } check_word_size(); @@ -1185,67 +1185,67 @@ mod tests { #[test] fn test_cast_range_i8_min() { - assert_eq!(i8::min_value.to_int(), Some(i8::min_value as int)); - assert_eq!(i8::min_value.to_i8(), Some(i8::min_value as i8)); - assert_eq!(i8::min_value.to_i16(), Some(i8::min_value as i16)); - assert_eq!(i8::min_value.to_i32(), Some(i8::min_value as i32)); - assert_eq!(i8::min_value.to_i64(), Some(i8::min_value as i64)); - assert_eq!(i8::min_value.to_uint(), None); - assert_eq!(i8::min_value.to_u8(), None); - assert_eq!(i8::min_value.to_u16(), None); - assert_eq!(i8::min_value.to_u32(), None); - assert_eq!(i8::min_value.to_u64(), None); + assert_eq!(i8::MIN.to_int(), Some(i8::MIN as int)); + 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)); + assert_eq!(i8::MIN.to_i64(), Some(i8::MIN as i64)); + assert_eq!(i8::MIN.to_uint(), None); + assert_eq!(i8::MIN.to_u8(), None); + assert_eq!(i8::MIN.to_u16(), None); + assert_eq!(i8::MIN.to_u32(), None); + assert_eq!(i8::MIN.to_u64(), None); } #[test] fn test_cast_range_i16_min() { - assert_eq!(i16::min_value.to_int(), Some(i16::min_value as int)); - assert_eq!(i16::min_value.to_i8(), None); - assert_eq!(i16::min_value.to_i16(), Some(i16::min_value as i16)); - assert_eq!(i16::min_value.to_i32(), Some(i16::min_value as i32)); - assert_eq!(i16::min_value.to_i64(), Some(i16::min_value as i64)); - assert_eq!(i16::min_value.to_uint(), None); - assert_eq!(i16::min_value.to_u8(), None); - assert_eq!(i16::min_value.to_u16(), None); - assert_eq!(i16::min_value.to_u32(), None); - assert_eq!(i16::min_value.to_u64(), None); + assert_eq!(i16::MIN.to_int(), Some(i16::MIN as int)); + 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)); + assert_eq!(i16::MIN.to_i64(), Some(i16::MIN as i64)); + assert_eq!(i16::MIN.to_uint(), None); + assert_eq!(i16::MIN.to_u8(), None); + assert_eq!(i16::MIN.to_u16(), None); + assert_eq!(i16::MIN.to_u32(), None); + assert_eq!(i16::MIN.to_u64(), None); } #[test] fn test_cast_range_i32_min() { - assert_eq!(i32::min_value.to_int(), Some(i32::min_value as int)); - assert_eq!(i32::min_value.to_i8(), None); - assert_eq!(i32::min_value.to_i16(), None); - assert_eq!(i32::min_value.to_i32(), Some(i32::min_value as i32)); - assert_eq!(i32::min_value.to_i64(), Some(i32::min_value as i64)); - assert_eq!(i32::min_value.to_uint(), None); - assert_eq!(i32::min_value.to_u8(), None); - assert_eq!(i32::min_value.to_u16(), None); - assert_eq!(i32::min_value.to_u32(), None); - assert_eq!(i32::min_value.to_u64(), None); + assert_eq!(i32::MIN.to_int(), Some(i32::MIN as int)); + 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)); + assert_eq!(i32::MIN.to_i64(), Some(i32::MIN as i64)); + assert_eq!(i32::MIN.to_uint(), None); + assert_eq!(i32::MIN.to_u8(), None); + assert_eq!(i32::MIN.to_u16(), None); + assert_eq!(i32::MIN.to_u32(), None); + assert_eq!(i32::MIN.to_u64(), None); } #[test] fn test_cast_range_i64_min() { - // i64::min_value.to_int() is word-size specific - assert_eq!(i64::min_value.to_i8(), None); - assert_eq!(i64::min_value.to_i16(), None); - assert_eq!(i64::min_value.to_i32(), None); - assert_eq!(i64::min_value.to_i64(), Some(i64::min_value as i64)); - assert_eq!(i64::min_value.to_uint(), None); - assert_eq!(i64::min_value.to_u8(), None); - assert_eq!(i64::min_value.to_u16(), None); - assert_eq!(i64::min_value.to_u32(), None); - assert_eq!(i64::min_value.to_u64(), None); + // i64::MIN.to_int() is word-size specific + assert_eq!(i64::MIN.to_i8(), None); + assert_eq!(i64::MIN.to_i16(), None); + assert_eq!(i64::MIN.to_i32(), None); + assert_eq!(i64::MIN.to_i64(), Some(i64::MIN as i64)); + assert_eq!(i64::MIN.to_uint(), None); + assert_eq!(i64::MIN.to_u8(), None); + assert_eq!(i64::MIN.to_u16(), None); + assert_eq!(i64::MIN.to_u32(), None); + assert_eq!(i64::MIN.to_u64(), None); #[cfg(target_word_size = "32")] fn check_word_size() { - assert_eq!(i64::min_value.to_int(), None); + assert_eq!(i64::MIN.to_int(), None); } #[cfg(target_word_size = "64")] fn check_word_size() { - assert_eq!(i64::min_value.to_int(), Some(i64::min_value as int)); + assert_eq!(i64::MIN.to_int(), Some(i64::MIN as int)); } check_word_size(); @@ -1253,26 +1253,26 @@ mod tests { #[test] fn test_cast_range_int_max() { - assert_eq!(int::max_value.to_int(), Some(int::max_value as int)); - assert_eq!(int::max_value.to_i8(), None); - assert_eq!(int::max_value.to_i16(), None); - // int::max_value.to_i32() is word-size specific - assert_eq!(int::max_value.to_i64(), Some(int::max_value as i64)); - assert_eq!(int::max_value.to_u8(), None); - assert_eq!(int::max_value.to_u16(), None); - // int::max_value.to_u32() is word-size specific - assert_eq!(int::max_value.to_u64(), Some(int::max_value as u64)); + 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)); #[cfg(target_word_size = "32")] fn check_word_size() { - assert_eq!(int::max_value.to_i32(), Some(int::max_value as i32)); - assert_eq!(int::max_value.to_u32(), Some(int::max_value as u32)); + assert_eq!(int::MAX.to_i32(), Some(int::MAX as i32)); + assert_eq!(int::MAX.to_u32(), Some(int::MAX as u32)); } #[cfg(target_word_size = "64")] fn check_word_size() { - assert_eq!(int::max_value.to_i32(), None); - assert_eq!(int::max_value.to_u32(), None); + assert_eq!(int::MAX.to_i32(), None); + assert_eq!(int::MAX.to_u32(), None); } check_word_size(); @@ -1280,69 +1280,69 @@ mod tests { #[test] fn test_cast_range_i8_max() { - assert_eq!(i8::max_value.to_int(), Some(i8::max_value as int)); - assert_eq!(i8::max_value.to_i8(), Some(i8::max_value as i8)); - assert_eq!(i8::max_value.to_i16(), Some(i8::max_value as i16)); - assert_eq!(i8::max_value.to_i32(), Some(i8::max_value as i32)); - assert_eq!(i8::max_value.to_i64(), Some(i8::max_value as i64)); - assert_eq!(i8::max_value.to_uint(), Some(i8::max_value as uint)); - assert_eq!(i8::max_value.to_u8(), Some(i8::max_value as u8)); - assert_eq!(i8::max_value.to_u16(), Some(i8::max_value as u16)); - assert_eq!(i8::max_value.to_u32(), Some(i8::max_value as u32)); - assert_eq!(i8::max_value.to_u64(), Some(i8::max_value as u64)); + assert_eq!(i8::MAX.to_int(), Some(i8::MAX as int)); + 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_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)); + assert_eq!(i8::MAX.to_u64(), Some(i8::MAX as u64)); } #[test] fn test_cast_range_i16_max() { - assert_eq!(i16::max_value.to_int(), Some(i16::max_value as int)); - assert_eq!(i16::max_value.to_i8(), None); - assert_eq!(i16::max_value.to_i16(), Some(i16::max_value as i16)); - assert_eq!(i16::max_value.to_i32(), Some(i16::max_value as i32)); - assert_eq!(i16::max_value.to_i64(), Some(i16::max_value as i64)); - assert_eq!(i16::max_value.to_uint(), Some(i16::max_value as uint)); - assert_eq!(i16::max_value.to_u8(), None); - assert_eq!(i16::max_value.to_u16(), Some(i16::max_value as u16)); - assert_eq!(i16::max_value.to_u32(), Some(i16::max_value as u32)); - assert_eq!(i16::max_value.to_u64(), Some(i16::max_value as u64)); + assert_eq!(i16::MAX.to_int(), Some(i16::MAX as int)); + 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_u8(), None); + assert_eq!(i16::MAX.to_u16(), Some(i16::MAX as u16)); + assert_eq!(i16::MAX.to_u32(), Some(i16::MAX as u32)); + assert_eq!(i16::MAX.to_u64(), Some(i16::MAX as u64)); } #[test] fn test_cast_range_i32_max() { - assert_eq!(i32::max_value.to_int(), Some(i32::max_value as int)); - assert_eq!(i32::max_value.to_i8(), None); - assert_eq!(i32::max_value.to_i16(), None); - assert_eq!(i32::max_value.to_i32(), Some(i32::max_value as i32)); - assert_eq!(i32::max_value.to_i64(), Some(i32::max_value as i64)); - assert_eq!(i32::max_value.to_uint(), Some(i32::max_value as uint)); - assert_eq!(i32::max_value.to_u8(), None); - assert_eq!(i32::max_value.to_u16(), None); - assert_eq!(i32::max_value.to_u32(), Some(i32::max_value as u32)); - assert_eq!(i32::max_value.to_u64(), Some(i32::max_value as u64)); + assert_eq!(i32::MAX.to_int(), Some(i32::MAX as int)); + 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_u8(), None); + assert_eq!(i32::MAX.to_u16(), None); + assert_eq!(i32::MAX.to_u32(), Some(i32::MAX as u32)); + assert_eq!(i32::MAX.to_u64(), Some(i32::MAX as u64)); } #[test] fn test_cast_range_i64_max() { - // i64::max_value.to_int() is word-size specific - assert_eq!(i64::max_value.to_i8(), None); - assert_eq!(i64::max_value.to_i16(), None); - assert_eq!(i64::max_value.to_i32(), None); - assert_eq!(i64::max_value.to_i64(), Some(i64::max_value as i64)); - // i64::max_value.to_uint() is word-size specific - assert_eq!(i64::max_value.to_u8(), None); - assert_eq!(i64::max_value.to_u16(), None); - assert_eq!(i64::max_value.to_u32(), None); - assert_eq!(i64::max_value.to_u64(), Some(i64::max_value as u64)); + // i64::MAX.to_int() is word-size specific + assert_eq!(i64::MAX.to_i8(), None); + assert_eq!(i64::MAX.to_i16(), None); + assert_eq!(i64::MAX.to_i32(), None); + assert_eq!(i64::MAX.to_i64(), Some(i64::MAX as i64)); + // i64::MAX.to_uint() is word-size specific + assert_eq!(i64::MAX.to_u8(), None); + assert_eq!(i64::MAX.to_u16(), None); + assert_eq!(i64::MAX.to_u32(), None); + assert_eq!(i64::MAX.to_u64(), Some(i64::MAX as u64)); #[cfg(target_word_size = "32")] fn check_word_size() { - assert_eq!(i64::max_value.to_int(), None); - assert_eq!(i64::max_value.to_uint(), None); + assert_eq!(i64::MAX.to_int(), None); + assert_eq!(i64::MAX.to_uint(), None); } #[cfg(target_word_size = "64")] fn check_word_size() { - assert_eq!(i64::max_value.to_int(), Some(i64::max_value as int)); - assert_eq!(i64::max_value.to_uint(), Some(i64::max_value as uint)); + assert_eq!(i64::MAX.to_int(), Some(i64::MAX as int)); + assert_eq!(i64::MAX.to_uint(), Some(i64::MAX as uint)); } check_word_size(); @@ -1350,96 +1350,96 @@ mod tests { #[test] fn test_cast_range_uint_min() { - assert_eq!(uint::min_value.to_int(), Some(uint::min_value as int)); - assert_eq!(uint::min_value.to_i8(), Some(uint::min_value as i8)); - assert_eq!(uint::min_value.to_i16(), Some(uint::min_value as i16)); - assert_eq!(uint::min_value.to_i32(), Some(uint::min_value as i32)); - assert_eq!(uint::min_value.to_i64(), Some(uint::min_value as i64)); - assert_eq!(uint::min_value.to_uint(), Some(uint::min_value as uint)); - assert_eq!(uint::min_value.to_u8(), Some(uint::min_value as u8)); - assert_eq!(uint::min_value.to_u16(), Some(uint::min_value as u16)); - assert_eq!(uint::min_value.to_u32(), Some(uint::min_value as u32)); - assert_eq!(uint::min_value.to_u64(), Some(uint::min_value as u64)); + 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)); } #[test] fn test_cast_range_u8_min() { - assert_eq!(u8::min_value.to_int(), Some(u8::min_value as int)); - assert_eq!(u8::min_value.to_i8(), Some(u8::min_value as i8)); - assert_eq!(u8::min_value.to_i16(), Some(u8::min_value as i16)); - assert_eq!(u8::min_value.to_i32(), Some(u8::min_value as i32)); - assert_eq!(u8::min_value.to_i64(), Some(u8::min_value as i64)); - assert_eq!(u8::min_value.to_uint(), Some(u8::min_value as uint)); - assert_eq!(u8::min_value.to_u8(), Some(u8::min_value as u8)); - assert_eq!(u8::min_value.to_u16(), Some(u8::min_value as u16)); - assert_eq!(u8::min_value.to_u32(), Some(u8::min_value as u32)); - assert_eq!(u8::min_value.to_u64(), Some(u8::min_value as u64)); + assert_eq!(u8::MIN.to_int(), Some(u8::MIN as int)); + 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_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)); + assert_eq!(u8::MIN.to_u64(), Some(u8::MIN as u64)); } #[test] fn test_cast_range_u16_min() { - assert_eq!(u16::min_value.to_int(), Some(u16::min_value as int)); - assert_eq!(u16::min_value.to_i8(), Some(u16::min_value as i8)); - assert_eq!(u16::min_value.to_i16(), Some(u16::min_value as i16)); - assert_eq!(u16::min_value.to_i32(), Some(u16::min_value as i32)); - assert_eq!(u16::min_value.to_i64(), Some(u16::min_value as i64)); - assert_eq!(u16::min_value.to_uint(), Some(u16::min_value as uint)); - assert_eq!(u16::min_value.to_u8(), Some(u16::min_value as u8)); - assert_eq!(u16::min_value.to_u16(), Some(u16::min_value as u16)); - assert_eq!(u16::min_value.to_u32(), Some(u16::min_value as u32)); - assert_eq!(u16::min_value.to_u64(), Some(u16::min_value as u64)); + assert_eq!(u16::MIN.to_int(), Some(u16::MIN as int)); + 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_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)); + assert_eq!(u16::MIN.to_u64(), Some(u16::MIN as u64)); } #[test] fn test_cast_range_u32_min() { - assert_eq!(u32::min_value.to_int(), Some(u32::min_value as int)); - assert_eq!(u32::min_value.to_i8(), Some(u32::min_value as i8)); - assert_eq!(u32::min_value.to_i16(), Some(u32::min_value as i16)); - assert_eq!(u32::min_value.to_i32(), Some(u32::min_value as i32)); - assert_eq!(u32::min_value.to_i64(), Some(u32::min_value as i64)); - assert_eq!(u32::min_value.to_uint(), Some(u32::min_value as uint)); - assert_eq!(u32::min_value.to_u8(), Some(u32::min_value as u8)); - assert_eq!(u32::min_value.to_u16(), Some(u32::min_value as u16)); - assert_eq!(u32::min_value.to_u32(), Some(u32::min_value as u32)); - assert_eq!(u32::min_value.to_u64(), Some(u32::min_value as u64)); + assert_eq!(u32::MIN.to_int(), Some(u32::MIN as int)); + 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_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)); + assert_eq!(u32::MIN.to_u64(), Some(u32::MIN as u64)); } #[test] fn test_cast_range_u64_min() { - assert_eq!(u64::min_value.to_int(), Some(u64::min_value as int)); - assert_eq!(u64::min_value.to_i8(), Some(u64::min_value as i8)); - assert_eq!(u64::min_value.to_i16(), Some(u64::min_value as i16)); - assert_eq!(u64::min_value.to_i32(), Some(u64::min_value as i32)); - assert_eq!(u64::min_value.to_i64(), Some(u64::min_value as i64)); - assert_eq!(u64::min_value.to_uint(), Some(u64::min_value as uint)); - assert_eq!(u64::min_value.to_u8(), Some(u64::min_value as u8)); - assert_eq!(u64::min_value.to_u16(), Some(u64::min_value as u16)); - assert_eq!(u64::min_value.to_u32(), Some(u64::min_value as u32)); - assert_eq!(u64::min_value.to_u64(), Some(u64::min_value as u64)); + assert_eq!(u64::MIN.to_int(), Some(u64::MIN as int)); + 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_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)); + assert_eq!(u64::MIN.to_u64(), Some(u64::MIN as u64)); } #[test] fn test_cast_range_uint_max() { - assert_eq!(uint::max_value.to_int(), None); - assert_eq!(uint::max_value.to_i8(), None); - assert_eq!(uint::max_value.to_i16(), None); - assert_eq!(uint::max_value.to_i32(), None); - // uint::max_value.to_i64() is word-size specific - assert_eq!(uint::max_value.to_u8(), None); - assert_eq!(uint::max_value.to_u16(), None); - // uint::max_value.to_u32() is word-size specific - assert_eq!(uint::max_value.to_u64(), Some(uint::max_value as u64)); + 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)); #[cfg(target_word_size = "32")] fn check_word_size() { - assert_eq!(uint::max_value.to_u32(), Some(uint::max_value as u32)); - assert_eq!(uint::max_value.to_i64(), Some(uint::max_value as i64)); + assert_eq!(uint::MAX.to_u32(), Some(uint::MAX as u32)); + assert_eq!(uint::MAX.to_i64(), Some(uint::MAX as i64)); } #[cfg(target_word_size = "64")] fn check_word_size() { - assert_eq!(uint::max_value.to_u32(), None); - assert_eq!(uint::max_value.to_i64(), None); + assert_eq!(uint::MAX.to_u32(), None); + assert_eq!(uint::MAX.to_i64(), None); } check_word_size(); @@ -1447,53 +1447,53 @@ mod tests { #[test] fn test_cast_range_u8_max() { - assert_eq!(u8::max_value.to_int(), Some(u8::max_value as int)); - assert_eq!(u8::max_value.to_i8(), None); - assert_eq!(u8::max_value.to_i16(), Some(u8::max_value as i16)); - assert_eq!(u8::max_value.to_i32(), Some(u8::max_value as i32)); - assert_eq!(u8::max_value.to_i64(), Some(u8::max_value as i64)); - assert_eq!(u8::max_value.to_uint(), Some(u8::max_value as uint)); - assert_eq!(u8::max_value.to_u8(), Some(u8::max_value as u8)); - assert_eq!(u8::max_value.to_u16(), Some(u8::max_value as u16)); - assert_eq!(u8::max_value.to_u32(), Some(u8::max_value as u32)); - assert_eq!(u8::max_value.to_u64(), Some(u8::max_value as u64)); + assert_eq!(u8::MAX.to_int(), Some(u8::MAX as int)); + 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_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)); + assert_eq!(u8::MAX.to_u64(), Some(u8::MAX as u64)); } #[test] fn test_cast_range_u16_max() { - assert_eq!(u16::max_value.to_int(), Some(u16::max_value as int)); - assert_eq!(u16::max_value.to_i8(), None); - assert_eq!(u16::max_value.to_i16(), None); - assert_eq!(u16::max_value.to_i32(), Some(u16::max_value as i32)); - assert_eq!(u16::max_value.to_i64(), Some(u16::max_value as i64)); - assert_eq!(u16::max_value.to_uint(), Some(u16::max_value as uint)); - assert_eq!(u16::max_value.to_u8(), None); - assert_eq!(u16::max_value.to_u16(), Some(u16::max_value as u16)); - assert_eq!(u16::max_value.to_u32(), Some(u16::max_value as u32)); - assert_eq!(u16::max_value.to_u64(), Some(u16::max_value as u64)); + assert_eq!(u16::MAX.to_int(), Some(u16::MAX as int)); + 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_u8(), None); + assert_eq!(u16::MAX.to_u16(), Some(u16::MAX as u16)); + assert_eq!(u16::MAX.to_u32(), Some(u16::MAX as u32)); + assert_eq!(u16::MAX.to_u64(), Some(u16::MAX as u64)); } #[test] fn test_cast_range_u32_max() { - // u32::max_value.to_int() is word-size specific - assert_eq!(u32::max_value.to_i8(), None); - assert_eq!(u32::max_value.to_i16(), None); - assert_eq!(u32::max_value.to_i32(), None); - assert_eq!(u32::max_value.to_i64(), Some(u32::max_value as i64)); - assert_eq!(u32::max_value.to_uint(), Some(u32::max_value as uint)); - assert_eq!(u32::max_value.to_u8(), None); - assert_eq!(u32::max_value.to_u16(), None); - assert_eq!(u32::max_value.to_u32(), Some(u32::max_value as u32)); - assert_eq!(u32::max_value.to_u64(), Some(u32::max_value as u64)); + // u32::MAX.to_int() is word-size specific + assert_eq!(u32::MAX.to_i8(), None); + 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_u8(), None); + assert_eq!(u32::MAX.to_u16(), None); + assert_eq!(u32::MAX.to_u32(), Some(u32::MAX as u32)); + assert_eq!(u32::MAX.to_u64(), Some(u32::MAX as u64)); #[cfg(target_word_size = "32")] fn check_word_size() { - assert_eq!(u32::max_value.to_int(), None); + assert_eq!(u32::MAX.to_int(), None); } #[cfg(target_word_size = "64")] fn check_word_size() { - assert_eq!(u32::max_value.to_int(), Some(u32::max_value as int)); + assert_eq!(u32::MAX.to_int(), Some(u32::MAX as int)); } check_word_size(); @@ -1501,25 +1501,25 @@ mod tests { #[test] fn test_cast_range_u64_max() { - assert_eq!(u64::max_value.to_int(), None); - assert_eq!(u64::max_value.to_i8(), None); - assert_eq!(u64::max_value.to_i16(), None); - assert_eq!(u64::max_value.to_i32(), None); - assert_eq!(u64::max_value.to_i64(), None); - // u64::max_value.to_uint() is word-size specific - assert_eq!(u64::max_value.to_u8(), None); - assert_eq!(u64::max_value.to_u16(), None); - assert_eq!(u64::max_value.to_u32(), None); - assert_eq!(u64::max_value.to_u64(), Some(u64::max_value as u64)); + assert_eq!(u64::MAX.to_int(), None); + assert_eq!(u64::MAX.to_i8(), None); + assert_eq!(u64::MAX.to_i16(), None); + assert_eq!(u64::MAX.to_i32(), None); + assert_eq!(u64::MAX.to_i64(), None); + // u64::MAX.to_uint() is word-size specific + assert_eq!(u64::MAX.to_u8(), None); + assert_eq!(u64::MAX.to_u16(), None); + assert_eq!(u64::MAX.to_u32(), None); + assert_eq!(u64::MAX.to_u64(), Some(u64::MAX as u64)); #[cfg(target_word_size = "32")] fn check_word_size() { - assert_eq!(u64::max_value.to_uint(), None); + assert_eq!(u64::MAX.to_uint(), None); } #[cfg(target_word_size = "64")] fn check_word_size() { - assert_eq!(u64::max_value.to_uint(), Some(u64::max_value as uint)); + assert_eq!(u64::MAX.to_uint(), Some(u64::MAX as uint)); } check_word_size(); @@ -1527,55 +1527,55 @@ mod tests { #[test] fn test_saturating_add_uint() { - use uint::max_value; + use uint::MAX; assert_eq!(3u.saturating_add(5u), 8u); - assert_eq!(3u.saturating_add(max_value-1), max_value); - assert_eq!(max_value.saturating_add(max_value), max_value); - assert_eq!((max_value-2).saturating_add(1), max_value-1); + assert_eq!(3u.saturating_add(MAX-1), MAX); + assert_eq!(MAX.saturating_add(MAX), MAX); + assert_eq!((MAX-2).saturating_add(1), MAX-1); } #[test] fn test_saturating_sub_uint() { - use uint::max_value; + use uint::MAX; assert_eq!(5u.saturating_sub(3u), 2u); assert_eq!(3u.saturating_sub(5u), 0u); assert_eq!(0u.saturating_sub(1u), 0u); - assert_eq!((max_value-1).saturating_sub(max_value), 0); + assert_eq!((MAX-1).saturating_sub(MAX), 0); } #[test] fn test_saturating_add_int() { - use int::{min_value,max_value}; + use int::{MIN,MAX}; assert_eq!(3i.saturating_add(5i), 8i); - assert_eq!(3i.saturating_add(max_value-1), max_value); - assert_eq!(max_value.saturating_add(max_value), max_value); - assert_eq!((max_value-2).saturating_add(1), max_value-1); + assert_eq!(3i.saturating_add(MAX-1), MAX); + assert_eq!(MAX.saturating_add(MAX), MAX); + assert_eq!((MAX-2).saturating_add(1), MAX-1); assert_eq!(3i.saturating_add(-5i), -2i); - assert_eq!(min_value.saturating_add(-1i), min_value); - assert_eq!((-2i).saturating_add(-max_value), min_value); + assert_eq!(MIN.saturating_add(-1i), MIN); + assert_eq!((-2i).saturating_add(-MAX), MIN); } #[test] fn test_saturating_sub_int() { - use int::{min_value,max_value}; + use int::{MIN,MAX}; assert_eq!(3i.saturating_sub(5i), -2i); - assert_eq!(min_value.saturating_sub(1i), min_value); - assert_eq!((-2i).saturating_sub(max_value), min_value); + assert_eq!(MIN.saturating_sub(1i), MIN); + assert_eq!((-2i).saturating_sub(MAX), MIN); assert_eq!(3i.saturating_sub(-5i), 8i); - assert_eq!(3i.saturating_sub(-(max_value-1)), max_value); - assert_eq!(max_value.saturating_sub(-max_value), max_value); - assert_eq!((max_value-2).saturating_sub(-1), max_value-1); + assert_eq!(3i.saturating_sub(-(MAX-1)), MAX); + assert_eq!(MAX.saturating_sub(-MAX), MAX); + assert_eq!((MAX-2).saturating_sub(-1), MAX-1); } #[test] fn test_checked_add() { - let five_less = uint::max_value - 5; - assert_eq!(five_less.checked_add(&0), Some(uint::max_value - 5)); - assert_eq!(five_less.checked_add(&1), Some(uint::max_value - 4)); - assert_eq!(five_less.checked_add(&2), Some(uint::max_value - 3)); - assert_eq!(five_less.checked_add(&3), Some(uint::max_value - 2)); - assert_eq!(five_less.checked_add(&4), Some(uint::max_value - 1)); - assert_eq!(five_less.checked_add(&5), Some(uint::max_value)); + 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)); assert_eq!(five_less.checked_add(&6), None); assert_eq!(five_less.checked_add(&7), None); } @@ -1594,7 +1594,7 @@ mod tests { #[test] fn test_checked_mul() { - let third = uint::max_value / 3; + let third = uint::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)); diff --git a/src/libstd/num/uint.rs b/src/libstd/num/uint.rs index d304f947542..3eeae6283b3 100644 --- a/src/libstd/num/uint.rs +++ b/src/libstd/num/uint.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// 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. // @@ -25,7 +25,7 @@ use option::{Option, Some, None}; use str; use unstable::intrinsics; -uint_module!(uint, int, ::int::bits) +uint_module!(uint, int, ::int::BITS) /// /// Divide two numbers, return the result, rounded up. @@ -234,9 +234,9 @@ fn test_next_power_of_two() { #[test] fn test_overflows() { use uint; - assert!((uint::max_value > 0u)); - assert!((uint::min_value <= 0u)); - assert!((uint::min_value + uint::max_value + 1u == 0u)); + assert!((uint::MAX > 0u)); + assert!((uint::MIN <= 0u)); + assert!((uint::MIN + uint::MAX + 1u == 0u)); } #[test] diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs index 1b822a491c6..5b9767e68e8 100644 --- a/src/libstd/num/uint_macros.rs +++ b/src/libstd/num/uint_macros.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// 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. // @@ -13,11 +13,11 @@ macro_rules! uint_module (($T:ty, $T_SIGNED:ty, $bits:expr) => ( -pub static bits : uint = $bits; -pub static bytes : uint = ($bits / 8); +pub static BITS : uint = $bits; +pub static BYTES : uint = ($bits / 8); -pub static min_value: $T = 0 as $T; -pub static max_value: $T = 0 as $T - 1 as $T; +pub static MIN: $T = 0 as $T; +pub static MAX: $T = 0 as $T - 1 as $T; impl CheckedDiv for $T { #[inline] @@ -214,10 +214,10 @@ impl Not<$T> for $T { impl Bounded for $T { #[inline] - fn min_value() -> $T { min_value } + fn min_value() -> $T { MIN } #[inline] - fn max_value() -> $T { max_value } + fn max_value() -> $T { MAX } } impl Int for $T {} @@ -398,7 +398,7 @@ mod tests { assert_eq!(0b0110 as $T, (0b1100 as $T).bitxor(&(0b1010 as $T))); assert_eq!(0b1110 as $T, (0b0111 as $T).shl(&(1 as $T))); assert_eq!(0b0111 as $T, (0b1110 as $T).shr(&(1 as $T))); - assert_eq!(max_value - (0b1011 as $T), (0b1011 as $T).not()); + assert_eq!(MAX - (0b1011 as $T), (0b1011 as $T).not()); } #[test] diff --git a/src/libstd/option.rs b/src/libstd/option.rs index 53fa41f9cfd..833f2021043 100644 --- a/src/libstd/option.rs +++ b/src/libstd/option.rs @@ -1,4 +1,4 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// 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. // @@ -441,7 +441,7 @@ impl<A> ExactSize<A> for Item<A> {} /// checking for overflow: /// /// fn inc_conditionally(x: uint) -> Option<uint> { -/// if x == uint::max_value { return None; } +/// if x == uint::MAX { return None; } /// else { return Some(x+1u); } /// } /// let v = [1u, 2, 3]; diff --git a/src/libstd/rand/rand_impls.rs b/src/libstd/rand/rand_impls.rs index 1c90ef148fc..8f4752b3c44 100644 --- a/src/libstd/rand/rand_impls.rs +++ b/src/libstd/rand/rand_impls.rs @@ -1,4 +1,4 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -19,7 +19,7 @@ use uint; impl Rand for int { #[inline] fn rand<R: Rng>(rng: &mut R) -> int { - if int::bits == 32 { + if int::BITS == 32 { rng.gen::<i32>() as int } else { rng.gen::<i64>() as int @@ -58,7 +58,7 @@ impl Rand for i64 { impl Rand for uint { #[inline] fn rand<R: Rng>(rng: &mut R) -> uint { - if uint::bits == 32 { + if uint::BITS == 32 { rng.gen::<u32>() as uint } else { rng.gen::<u64>() as uint diff --git a/src/libstd/result.rs b/src/libstd/result.rs index 1a4e6d5bcfd..62049e8b4c9 100644 --- a/src/libstd/result.rs +++ b/src/libstd/result.rs @@ -1,4 +1,4 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// 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. // @@ -227,7 +227,7 @@ impl<T: fmt::Default, E: fmt::Default> fmt::Default for Result<T, E> { /// checking for overflow: /// /// fn inc_conditionally(x: uint) -> Result<uint, &'static str> { -/// if x == uint::max_value { return Err("overflow"); } +/// if x == uint::MAX { return Err("overflow"); } /// else { return Ok(x+1u); } /// } /// let v = [1u, 2, 3]; diff --git a/src/libstd/rt/thread.rs b/src/libstd/rt/thread.rs index b5262424c06..d543af1bf9b 100644 --- a/src/libstd/rt/thread.rs +++ b/src/libstd/rt/thread.rs @@ -1,4 +1,4 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -43,7 +43,7 @@ static DEFAULT_STACK_SIZE: uint = 1024 * 1024; extern fn thread_start(main: *libc::c_void) -> imp::rust_thread_return { use unstable::stack; unsafe { - stack::record_stack_bounds(0, uint::max_value); + stack::record_stack_bounds(0, uint::MAX); let f: ~proc() = cast::transmute(main); (*f)(); cast::transmute(0 as imp::rust_thread_return) diff --git a/src/libstd/trie.rs b/src/libstd/trie.rs index 8b9b41f027c..ef0930fabf1 100644 --- a/src/libstd/trie.rs +++ b/src/libstd/trie.rs @@ -1,4 +1,4 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -21,7 +21,7 @@ use vec; static SHIFT: uint = 4; static SIZE: uint = 1 << SHIFT; static MASK: uint = SIZE - 1; -static NUM_CHUNKS: uint = uint::bits / SHIFT; +static NUM_CHUNKS: uint = uint::BITS / SHIFT; enum Child<T> { Internal(~TrieNode<T>), @@ -396,7 +396,7 @@ impl<T> TrieNode<T> { // if this was done via a trait, the key could be generic #[inline] fn chunk(n: uint, idx: uint) -> uint { - let sh = uint::bits - (SHIFT * (idx + 1)); + let sh = uint::BITS - (SHIFT * (idx + 1)); (n >> sh) & MASK } @@ -728,14 +728,14 @@ mod test_map { fn test_each_reverse_break() { let mut m = TrieMap::new(); - for x in range(uint::max_value - 10000, uint::max_value).rev() { + for x in range(uint::MAX - 10000, uint::MAX).rev() { m.insert(x, x / 2); } - let mut n = uint::max_value - 1; + let mut n = uint::MAX - 1; m.each_reverse(|k, v| { - if n == uint::max_value - 5000 { false } else { - assert!(n > uint::max_value - 5000); + if n == uint::MAX - 5000 { false } else { + assert!(n > uint::MAX - 5000); assert_eq!(*k, n); assert_eq!(*v, n / 2); @@ -777,8 +777,8 @@ mod test_map { let empty_map : TrieMap<uint> = TrieMap::new(); assert_eq!(empty_map.iter().next(), None); - let first = uint::max_value - 10000; - let last = uint::max_value; + let first = uint::MAX - 10000; + let last = uint::MAX; let mut map = TrieMap::new(); for x in range(first, last).rev() { @@ -799,8 +799,8 @@ mod test_map { let mut empty_map : TrieMap<uint> = TrieMap::new(); assert!(empty_map.mut_iter().next().is_none()); - let first = uint::max_value - 10000; - let last = uint::max_value; + let first = uint::MAX - 10000; + let last = uint::MAX; let mut map = TrieMap::new(); for x in range(first, last).rev() { @@ -1014,7 +1014,7 @@ mod test_set { #[test] fn test_sane_chunk() { let x = 1; - let y = 1 << (uint::bits - 1); + let y = 1 << (uint::BITS - 1); let mut trie = TrieSet::new(); diff --git a/src/libstd/unstable/mutex.rs b/src/libstd/unstable/mutex.rs index 69c6204cc32..ba965f2b5c5 100644 --- a/src/libstd/unstable/mutex.rs +++ b/src/libstd/unstable/mutex.rs @@ -1,4 +1,4 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -389,9 +389,9 @@ impl Once { let prev = self.cnt.fetch_add(1, atomics::SeqCst); if prev < 0 { - // Make sure we never overflow, we'll never have int::min_value + // Make sure we never overflow, we'll never have int::MIN // simultaneous calls to `doit` to make this value go back to 0 - self.cnt.store(int::min_value, atomics::SeqCst); + self.cnt.store(int::MIN, atomics::SeqCst); return } @@ -401,7 +401,7 @@ impl Once { unsafe { self.mutex.lock() } if self.cnt.load(atomics::SeqCst) > 0 { f(); - let prev = self.cnt.swap(int::min_value, atomics::SeqCst); + let prev = self.cnt.swap(int::MIN, atomics::SeqCst); self.lock_cnt.store(prev, atomics::SeqCst); } unsafe { self.mutex.unlock() } diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index 41cae372dbb..3cc05ee8228 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -1,4 +1,4 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// 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. // @@ -1072,7 +1072,7 @@ impl<'a,T> ImmutableVector<'a, T> for &'a [T] { #[inline] fn split(self, pred: 'a |&T| -> bool) -> Splits<'a, T> { - self.splitn(uint::max_value, pred) + self.splitn(uint::MAX, pred) } #[inline] @@ -1087,7 +1087,7 @@ impl<'a,T> ImmutableVector<'a, T> for &'a [T] { #[inline] fn rsplit(self, pred: 'a |&T| -> bool) -> RevSplits<'a, T> { - self.rsplitn(uint::max_value, pred) + self.rsplitn(uint::MAX, pred) } #[inline] |
