diff options
| author | Florian Zeitz <florob@babelmonkeys.de> | 2015-02-27 15:36:53 +0100 |
|---|---|---|
| committer | Florian Zeitz <florob@babelmonkeys.de> | 2015-03-02 17:11:51 +0100 |
| commit | f35f973cb700c444d8c029ee13b37dc16d560225 (patch) | |
| tree | 7d87e40045e89a5d75001ef4b241840870b6aed7 /src/libcollections | |
| parent | 1cc8b6ec664f30b43f75551e95299d943c8a4e6a (diff) | |
| download | rust-f35f973cb700c444d8c029ee13b37dc16d560225.tar.gz rust-f35f973cb700c444d8c029ee13b37dc16d560225.zip | |
Use `const`s instead of `static`s where appropriate
This changes the type of some public constants/statics in libunicode. Notably some `&'static &'static [(char, char)]` have changed to `&'static [(char, char)]`. The regexp crate seems to be the sole user of these, yet this is technically a [breaking-change]
Diffstat (limited to 'src/libcollections')
| -rw-r--r-- | src/libcollections/bit.rs | 4 | ||||
| -rw-r--r-- | src/libcollections/slice.rs | 4 | ||||
| -rw-r--r-- | src/libcollections/string.rs | 4 | ||||
| -rw-r--r-- | src/libcollections/vec_deque.rs | 4 |
4 files changed, 8 insertions, 8 deletions
diff --git a/src/libcollections/bit.rs b/src/libcollections/bit.rs index 5b19de42ac9..e9b6ec22d6d 100644 --- a/src/libcollections/bit.rs +++ b/src/libcollections/bit.rs @@ -2544,7 +2544,7 @@ mod bit_vec_bench { use super::BitVec; - static BENCH_BITS : usize = 1 << 14; + const BENCH_BITS : usize = 1 << 14; fn rng() -> rand::IsaacRng { let seed: &[_] = &[1, 2, 3, 4, 5, 6, 7, 8, 9, 0]; @@ -3039,7 +3039,7 @@ mod bit_set_bench { use super::{BitVec, BitSet}; - static BENCH_BITS : usize = 1 << 14; + const BENCH_BITS : usize = 1 << 14; fn rng() -> rand::IsaacRng { let seed: &[_] = &[1, 2, 3, 4, 5, 6, 7, 8, 9, 0]; diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index a2924f8fe53..f4c8abbcff1 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -1343,8 +1343,8 @@ fn insertion_sort<T, F>(v: &mut [T], mut compare: F) where F: FnMut(&T, &T) -> O fn merge_sort<T, F>(v: &mut [T], mut compare: F) where F: FnMut(&T, &T) -> Ordering { // warning: this wildly uses unsafe. - static BASE_INSERTION: usize = 32; - static LARGE_INSERTION: usize = 16; + const BASE_INSERTION: usize = 32; + const LARGE_INSERTION: usize = 16; // FIXME #12092: smaller insertion runs seems to make sorting // vectors of large elements a little faster on some platforms, diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index 94abffa3db6..33189bd68bd 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -153,8 +153,8 @@ impl String { } } - static TAG_CONT_U8: u8 = 128u8; - static REPLACEMENT: &'static [u8] = b"\xEF\xBF\xBD"; // U+FFFD in UTF-8 + const TAG_CONT_U8: u8 = 128u8; + const REPLACEMENT: &'static [u8] = b"\xEF\xBF\xBD"; // U+FFFD in UTF-8 let total = v.len(); fn unsafe_get(xs: &[u8], i: usize) -> u8 { unsafe { *xs.get_unchecked(i) } diff --git a/src/libcollections/vec_deque.rs b/src/libcollections/vec_deque.rs index abcc0cef9f1..59ec066b83e 100644 --- a/src/libcollections/vec_deque.rs +++ b/src/libcollections/vec_deque.rs @@ -39,8 +39,8 @@ use alloc::heap; #[unstable(feature = "collections")] pub use VecDeque as RingBuf; -static INITIAL_CAPACITY: usize = 7; // 2^3 - 1 -static MINIMUM_CAPACITY: usize = 1; // 2 - 1 +const INITIAL_CAPACITY: usize = 7; // 2^3 - 1 +const MINIMUM_CAPACITY: usize = 1; // 2 - 1 /// `VecDeque` is a growable ring buffer, which can be used as a /// double-ended queue efficiently. |
