about summary refs log tree commit diff
path: root/src/libextra
diff options
context:
space:
mode:
authorChris Wong <lambda.fairy@gmail.com>2014-01-25 20:37:51 +1300
committerChris Wong <lambda.fairy@gmail.com>2014-01-25 21:38:25 +1300
commit988e4f0a1c2802921375271bdc19f03650c024d2 (patch)
treeb2d2913ca7575e8e52f2cf6e7975ca2f0f148286 /src/libextra
parentde57a22b9a8c8416cace31c9bd3ec4c9a6888017 (diff)
downloadrust-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/libextra')
-rw-r--r--src/libextra/bitv.rs62
-rw-r--r--src/libextra/ebml.rs6
-rw-r--r--src/libextra/getopts.rs4
-rw-r--r--src/libextra/num/bigint.rs42
4 files changed, 57 insertions, 57 deletions
diff --git a/src/libextra/bitv.rs b/src/libextra/bitv.rs
index 9df75ff044a..7211907f483 100644
--- a/src/libextra/bitv.rs
+++ b/src/libextra/bitv.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.
 //
@@ -121,8 +121,8 @@ struct BigBitv {
  */
 #[inline]
 fn big_mask(nbits: uint, elem: uint) -> uint {
-    let rmd = nbits % uint::bits;
-    let nelems = nbits/uint::bits + if rmd == 0 {0} else {1};
+    let rmd = nbits % uint::BITS;
+    let nelems = nbits/uint::BITS + if rmd == 0 {0} else {1};
 
     if elem < nelems - 1 || rmd == 0 {
         !0
@@ -192,16 +192,16 @@ impl BigBitv {
 
     #[inline]
     pub fn get(&self, i: uint) -> bool {
-        let w = i / uint::bits;
-        let b = i % uint::bits;
+        let w = i / uint::BITS;
+        let b = i % uint::BITS;
         let x = 1 & self.storage[w] >> b;
         x == 1
     }
 
     #[inline]
     pub fn set(&mut self, i: uint, x: bool) {
-        let w = i / uint::bits;
-        let b = i % uint::bits;
+        let w = i / uint::BITS;
+        let b = i % uint::BITS;
         let flag = 1 << b;
         self.storage[w] = if x { self.storage[w] | flag }
                           else { self.storage[w] & !flag };
@@ -269,20 +269,20 @@ impl Bitv {
 
 impl Bitv {
     pub fn new(nbits: uint, init: bool) -> Bitv {
-        let rep = if nbits < uint::bits {
+        let rep = if nbits < uint::BITS {
             Small(SmallBitv::new(if init {(1<<nbits)-1} else {0}))
-        } else if nbits == uint::bits {
+        } else if nbits == uint::BITS {
             Small(SmallBitv::new(if init {!0} else {0}))
         } else {
-            let exact = nbits % uint::bits == 0;
-            let nelems = nbits/uint::bits + if exact {0} else {1};
+            let exact = nbits % uint::BITS == 0;
+            let nelems = nbits/uint::BITS + if exact {0} else {1};
             let s =
                 if init {
                     if exact {
                         vec::from_elem(nelems, !0u)
                     } else {
                         let mut v = vec::from_elem(nelems-1, !0u);
-                        v.push((1<<nbits % uint::bits)-1);
+                        v.push((1<<nbits % uint::BITS)-1);
                         v
                     }
                 } else { vec::from_elem(nelems, 0u)};
@@ -576,7 +576,7 @@ fn iterate_bits(base: uint, bits: uint, f: |uint| -> bool) -> bool {
     if bits == 0 {
         return true;
     }
-    for i in range(0u, uint::bits) {
+    for i in range(0u, uint::BITS) {
         if bits & (1 << i) != 0 {
             if !f(base + i) {
                 return false;
@@ -680,7 +680,7 @@ impl BitvSet {
 
     /// Returns the capacity in bits for this bit vector. Inserting any
     /// element less than this amount will not trigger a resizing.
-    pub fn capacity(&self) -> uint { self.bitv.storage.len() * uint::bits }
+    pub fn capacity(&self) -> uint { self.bitv.storage.len() * uint::BITS }
 
     /// Consumes this set to return the underlying bit vector
     pub fn unwrap(self) -> Bitv {
@@ -693,7 +693,7 @@ impl BitvSet {
     fn other_op(&mut self, other: &BitvSet, f: |uint, uint| -> uint) {
         fn nbits(mut w: uint) -> uint {
             let mut bits = 0;
-            for _ in range(0u, uint::bits) {
+            for _ in range(0u, uint::BITS) {
                 if w == 0 {
                     break;
                 }
@@ -703,7 +703,7 @@ impl BitvSet {
             return bits;
         }
         if self.capacity() < other.capacity() {
-            self.bitv.storage.grow(other.capacity() / uint::bits, &0);
+            self.bitv.storage.grow(other.capacity() / uint::BITS, &0);
         }
         for (i, &w) in other.bitv.storage.iter().enumerate() {
             let old = self.bitv.storage[i];
@@ -808,7 +808,7 @@ impl Mutable for BitvSet {
 
 impl Set<uint> for BitvSet {
     fn contains(&self, value: &uint) -> bool {
-        *value < self.bitv.storage.len() * uint::bits && self.bitv.get(*value)
+        *value < self.bitv.storage.len() * uint::BITS && self.bitv.get(*value)
     }
 
     fn is_disjoint(&self, other: &BitvSet) -> bool {
@@ -846,7 +846,7 @@ impl MutableSet<uint> for BitvSet {
         }
         let nbits = self.capacity();
         if value >= nbits {
-            let newsize = num::max(value, nbits * 2) / uint::bits + 1;
+            let newsize = num::max(value, nbits * 2) / uint::BITS + 1;
             assert!(newsize > self.bitv.storage.len());
             self.bitv.storage.grow(newsize, &0);
         }
@@ -884,7 +884,7 @@ impl BitvSet {
         let min = num::min(self.bitv.storage.len(), other.bitv.storage.len());
         self.bitv.storage.slice(0, min).iter().enumerate()
             .zip(Repeat::new(&other.bitv.storage))
-            .map(|((i, &w), o_store)| (i * uint::bits, w, o_store[i]))
+            .map(|((i, &w), o_store)| (i * uint::BITS, w, o_store[i]))
     }
 
     /// Visits each word in `self` or `other` that extends beyond the other. This
@@ -903,11 +903,11 @@ impl BitvSet {
         if olen < slen {
             self.bitv.storage.slice_from(olen).iter().enumerate()
                 .zip(Repeat::new(olen))
-                .map(|((i, &w), min)| (true, (i + min) * uint::bits, w))
+                .map(|((i, &w), min)| (true, (i + min) * uint::BITS, w))
         } else {
             other.bitv.storage.slice_from(slen).iter().enumerate()
                 .zip(Repeat::new(slen))
-                .map(|((i, &w), min)| (false, (i + min) * uint::bits, w))
+                .map(|((i, &w), min)| (false, (i + min) * uint::BITS, w))
         }
     }
 }
@@ -1529,7 +1529,7 @@ mod tests {
 
         assert!(a.insert(1000));
         assert!(a.remove(&1000));
-        assert_eq!(a.capacity(), uint::bits);
+        assert_eq!(a.capacity(), uint::BITS);
     }
 
     #[test]
@@ -1561,16 +1561,16 @@ mod tests {
         let mut r = rng();
         let mut bitv = 0 as uint;
         b.iter(|| {
-            bitv |= (1 << ((r.next_u32() as uint) % uint::bits));
+            bitv |= (1 << ((r.next_u32() as uint) % uint::BITS));
         })
     }
 
     #[bench]
     fn bench_small_bitv_small(b: &mut BenchHarness) {
         let mut r = rng();
-        let mut bitv = SmallBitv::new(uint::bits);
+        let mut bitv = SmallBitv::new(uint::BITS);
         b.iter(|| {
-            bitv.set((r.next_u32() as uint) % uint::bits, true);
+            bitv.set((r.next_u32() as uint) % uint::BITS, true);
         })
     }
 
@@ -1579,7 +1579,7 @@ mod tests {
         let mut r = rng();
         let mut bitv = BigBitv::new(~[0]);
         b.iter(|| {
-            bitv.set((r.next_u32() as uint) % uint::bits, true);
+            bitv.set((r.next_u32() as uint) % uint::BITS, true);
         })
     }
 
@@ -1587,7 +1587,7 @@ mod tests {
     fn bench_big_bitv_big(b: &mut BenchHarness) {
         let mut r = rng();
         let mut storage = ~[];
-        storage.grow(BENCH_BITS / uint::bits, &0u);
+        storage.grow(BENCH_BITS / uint::BITS, &0u);
         let mut bitv = BigBitv::new(storage);
         b.iter(|| {
             bitv.set((r.next_u32() as uint) % BENCH_BITS, true);
@@ -1606,9 +1606,9 @@ mod tests {
     #[bench]
     fn bench_bitv_small(b: &mut BenchHarness) {
         let mut r = rng();
-        let mut bitv = Bitv::new(uint::bits, false);
+        let mut bitv = Bitv::new(uint::BITS, false);
         b.iter(|| {
-            bitv.set((r.next_u32() as uint) % uint::bits, true);
+            bitv.set((r.next_u32() as uint) % uint::BITS, true);
         })
     }
 
@@ -1617,7 +1617,7 @@ mod tests {
         let mut r = rng();
         let mut bitv = BitvSet::new();
         b.iter(|| {
-            bitv.insert((r.next_u32() as uint) % uint::bits);
+            bitv.insert((r.next_u32() as uint) % uint::BITS);
         })
     }
 
@@ -1641,7 +1641,7 @@ mod tests {
 
     #[bench]
     fn bench_btv_small_iter(b: &mut BenchHarness) {
-        let bitv = Bitv::new(uint::bits, false);
+        let bitv = Bitv::new(uint::BITS, false);
         b.iter(|| {
             let mut _sum = 0;
             for pres in bitv.iter() {
diff --git a/src/libextra/ebml.rs b/src/libextra/ebml.rs
index aac8253b842..a44cf2ec063 100644
--- a/src/libextra/ebml.rs
+++ b/src/libextra/ebml.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.
 //
@@ -364,7 +364,7 @@ pub mod reader {
         fn read_u8 (&mut self) -> u8  { doc_as_u8 (self.next_doc(EsU8 )) }
         fn read_uint(&mut self) -> uint {
             let v = doc_as_u64(self.next_doc(EsUint));
-            if v > (::std::uint::max_value as u64) {
+            if v > (::std::uint::MAX as u64) {
                 fail!("uint {} too large for this architecture", v);
             }
             v as uint
@@ -384,7 +384,7 @@ pub mod reader {
         }
         fn read_int(&mut self) -> int {
             let v = doc_as_u64(self.next_doc(EsInt)) as i64;
-            if v > (int::max_value as i64) || v < (int::min_value as i64) {
+            if v > (int::MAX as i64) || v < (int::MIN as i64) {
                 debug!("FIXME \\#6122: Removing this makes this function miscompile");
                 fail!("int {} out of range for this architecture", v);
             }
diff --git a/src/libextra/getopts.rs b/src/libextra/getopts.rs
index 10d28eaafb0..6fd1e805b1b 100644
--- a/src/libextra/getopts.rs
+++ b/src/libextra/getopts.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.
 //
@@ -848,7 +848,7 @@ pub mod groups {
         t("hello", 15, [~"hello"]);
         t("\nMary had a little lamb\nLittle lamb\n", 15,
             [~"Mary had a", ~"little lamb", ~"Little lamb"]);
-        t("\nMary had a little lamb\nLittle lamb\n", ::std::uint::max_value,
+        t("\nMary had a little lamb\nLittle lamb\n", ::std::uint::MAX,
             [~"Mary had a little lamb\nLittle lamb"]);
     }
 } // end groups module
diff --git a/src/libextra/num/bigint.rs b/src/libextra/num/bigint.rs
index 8729cf1b685..1e1c09431b6 100644
--- a/src/libextra/num/bigint.rs
+++ b/src/libextra/num/bigint.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.
 //
@@ -1186,7 +1186,7 @@ impl ToPrimitive for BigInt {
                     if n < m {
                         Some(-(n as i64))
                     } else if n == m {
-                        Some(i64::min_value)
+                        Some(i64::MIN)
                     } else {
                         None
                     }
@@ -1213,7 +1213,7 @@ impl FromPrimitive for BigInt {
                 Some(BigInt::from_biguint(Plus, n))
             })
         } else if n < 0 {
-            FromPrimitive::from_u64(u64::max_value - (n as u64) + 1).and_then(
+            FromPrimitive::from_u64(u64::MAX - (n as u64) + 1).and_then(
                 |n| {
                     Some(BigInt::from_biguint(Minus, n))
                 })
@@ -1625,7 +1625,7 @@ mod biguint_tests {
 
         check(Zero::zero(), 0);
         check(One::one(), 1);
-        check(i64::max_value.to_biguint().unwrap(), i64::max_value);
+        check(i64::MAX.to_biguint().unwrap(), i64::MAX);
 
         check(BigUint::new(~[                   ]), 0);
         check(BigUint::new(~[ 1                 ]), (1 << (0*BigDigit::bits)));
@@ -1635,9 +1635,9 @@ mod biguint_tests {
         check(BigUint::new(~[ 0,  0,  1         ]), (1 << (2*BigDigit::bits)));
         check(BigUint::new(~[-1, -1, -1         ]), (1 << (3*BigDigit::bits)) - 1);
         check(BigUint::new(~[ 0,  0,  0,  1     ]), (1 << (3*BigDigit::bits)));
-        check(BigUint::new(~[-1, -1, -1, -1 >> 1]), i64::max_value);
+        check(BigUint::new(~[-1, -1, -1, -1 >> 1]), i64::MAX);
 
-        assert_eq!(i64::min_value.to_biguint(), None);
+        assert_eq!(i64::MIN.to_biguint(), None);
         assert_eq!(BigUint::new(~[-1, -1, -1, -1    ]).to_i64(), None);
         assert_eq!(BigUint::new(~[ 0,  0,  0,  0,  1]).to_i64(), None);
         assert_eq!(BigUint::new(~[-1, -1, -1, -1, -1]).to_i64(), None);
@@ -1654,15 +1654,15 @@ mod biguint_tests {
 
         check(Zero::zero(), 0);
         check(One::one(), 1);
-        check(i64::max_value.to_biguint().unwrap(), i64::max_value);
+        check(i64::MAX.to_biguint().unwrap(), i64::MAX);
 
         check(BigUint::new(~[           ]), 0);
         check(BigUint::new(~[ 1         ]), (1 << (0*BigDigit::bits)));
         check(BigUint::new(~[-1         ]), (1 << (1*BigDigit::bits)) - 1);
         check(BigUint::new(~[ 0,  1     ]), (1 << (1*BigDigit::bits)));
-        check(BigUint::new(~[-1, -1 >> 1]), i64::max_value);
+        check(BigUint::new(~[-1, -1 >> 1]), i64::MAX);
 
-        assert_eq!(i64::min_value.to_biguint(), None);
+        assert_eq!(i64::MIN.to_biguint(), None);
         assert_eq!(BigUint::new(~[-1, -1    ]).to_i64(), None);
         assert_eq!(BigUint::new(~[ 0,  0,  1]).to_i64(), None);
         assert_eq!(BigUint::new(~[-1, -1, -1]).to_i64(), None);
@@ -1679,8 +1679,8 @@ mod biguint_tests {
 
         check(Zero::zero(), 0);
         check(One::one(), 1);
-        check(u64::min_value.to_biguint().unwrap(), u64::min_value);
-        check(u64::max_value.to_biguint().unwrap(), u64::max_value);
+        check(u64::MIN.to_biguint().unwrap(), u64::MIN);
+        check(u64::MAX.to_biguint().unwrap(), u64::MAX);
 
         check(BigUint::new(~[              ]), 0);
         check(BigUint::new(~[ 1            ]), (1 << (0*BigDigit::bits)));
@@ -1690,7 +1690,7 @@ mod biguint_tests {
         check(BigUint::new(~[ 0,  0,  1    ]), (1 << (2*BigDigit::bits)));
         check(BigUint::new(~[-1, -1, -1    ]), (1 << (3*BigDigit::bits)) - 1);
         check(BigUint::new(~[ 0,  0,  0,  1]), (1 << (3*BigDigit::bits)));
-        check(BigUint::new(~[-1, -1, -1, -1]), u64::max_value);
+        check(BigUint::new(~[-1, -1, -1, -1]), u64::MAX);
 
         assert_eq!(BigUint::new(~[ 0,  0,  0,  0,  1]).to_u64(), None);
         assert_eq!(BigUint::new(~[-1, -1, -1, -1, -1]).to_u64(), None);
@@ -1707,14 +1707,14 @@ mod biguint_tests {
 
         check(Zero::zero(), 0);
         check(One::one(), 1);
-        check(u64::min_value.to_biguint().unwrap(), u64::min_value);
-        check(u64::max_value.to_biguint().unwrap(), u64::max_value);
+        check(u64::MIN.to_biguint().unwrap(), u64::MIN);
+        check(u64::MAX.to_biguint().unwrap(), u64::MAX);
 
         check(BigUint::new(~[      ]), 0);
         check(BigUint::new(~[ 1    ]), (1 << (0*BigDigit::bits)));
         check(BigUint::new(~[-1    ]), (1 << (1*BigDigit::bits)) - 1);
         check(BigUint::new(~[ 0,  1]), (1 << (1*BigDigit::bits)));
-        check(BigUint::new(~[-1, -1]), u64::max_value);
+        check(BigUint::new(~[-1, -1]), u64::MAX);
 
         assert_eq!(BigUint::new(~[ 0,  0,  1]).to_u64(), None);
         assert_eq!(BigUint::new(~[-1, -1, -1]).to_u64(), None);
@@ -2166,11 +2166,11 @@ mod bigint_tests {
 
         check(Zero::zero(), 0);
         check(One::one(), 1);
-        check(i64::min_value.to_bigint().unwrap(), i64::min_value);
-        check(i64::max_value.to_bigint().unwrap(), i64::max_value);
+        check(i64::MIN.to_bigint().unwrap(), i64::MIN);
+        check(i64::MAX.to_bigint().unwrap(), i64::MAX);
 
         assert_eq!(
-            (i64::max_value as u64 + 1).to_bigint().unwrap().to_i64(),
+            (i64::MAX as u64 + 1).to_bigint().unwrap().to_i64(),
             None);
 
         assert_eq!(
@@ -2196,14 +2196,14 @@ mod bigint_tests {
 
         check(Zero::zero(), 0);
         check(One::one(), 1);
-        check(u64::min_value.to_bigint().unwrap(), u64::min_value);
-        check(u64::max_value.to_bigint().unwrap(), u64::max_value);
+        check(u64::MIN.to_bigint().unwrap(), u64::MIN);
+        check(u64::MAX.to_bigint().unwrap(), u64::MAX);
 
         assert_eq!(
             BigInt::from_biguint(Plus, BigUint::new(~[1, 2, 3, 4, 5])).to_u64(),
             None);
 
-        let max_value: BigUint = FromPrimitive::from_u64(u64::max_value).unwrap();
+        let max_value: BigUint = FromPrimitive::from_u64(u64::MAX).unwrap();
         assert_eq!(BigInt::from_biguint(Minus, max_value).to_u64(), None);
         assert_eq!(BigInt::from_biguint(Minus, BigUint::new(~[1, 2, 3, 4, 5])).to_u64(), None);
     }