Skip to content

Commit fd6c4cb

Browse files
committed
libcore: Change [const T] to const [T] everywhere
1 parent bc5cda3 commit fd6c4cb

24 files changed

+85
-259
lines changed

src/libcore/at_vec.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub mod rustrt {
3838

3939
/// Returns the number of elements the vector can hold without reallocating
4040
#[inline(always)]
41-
pub fn capacity<T>(v: @[const T]) -> uint {
41+
pub fn capacity<T>(v: @[T]) -> uint {
4242
unsafe {
4343
let repr: **raw::VecRepr =
4444
::cast::reinterpret_cast(&addr_of(&v));
@@ -60,7 +60,7 @@ pub fn capacity<T>(v: @[const T]) -> uint {
6060
*/
6161
#[inline(always)]
6262
pub fn build_sized<A>(size: uint, builder: &fn(push: &fn(v: A))) -> @[A] {
63-
let mut vec: @[const A] = @[];
63+
let mut vec: @[A] = @[];
6464
unsafe { raw::reserve(&mut vec, size); }
6565
builder(|+x| unsafe { raw::push(&mut vec, x) });
6666
return unsafe { transmute(vec) };
@@ -102,7 +102,7 @@ pub fn build_sized_opt<A>(size: Option<uint>,
102102

103103
// Appending
104104
#[inline(always)]
105-
pub fn append<T:Copy>(lhs: @[T], rhs: &[const T]) -> @[T] {
105+
pub fn append<T:Copy>(lhs: @[T], rhs: &const [T]) -> @[T] {
106106
do build_sized(lhs.len() + rhs.len()) |push| {
107107
for vec::each(lhs) |x| { push(*x); }
108108
for uint::range(0, rhs.len()) |i| { push(rhs[i]); }
@@ -174,9 +174,9 @@ pub mod traits {
174174
use kinds::Copy;
175175
use ops::Add;
176176

177-
impl<T:Copy> Add<&'self [const T],@[T]> for @[T] {
177+
impl<T:Copy> Add<&'self const [T],@[T]> for @[T] {
178178
#[inline(always)]
179-
fn add(&self, rhs: & &'self [const T]) -> @[T] {
179+
fn add(&self, rhs: & &'self const [T]) -> @[T] {
180180
append(*self, (*rhs))
181181
}
182182
}
@@ -207,13 +207,13 @@ pub mod raw {
207207
* the vector is actually the specified size.
208208
*/
209209
#[inline(always)]
210-
pub unsafe fn set_len<T>(v: @[const T], new_len: uint) {
210+
pub unsafe fn set_len<T>(v: @[T], new_len: uint) {
211211
let repr: **VecRepr = ::cast::reinterpret_cast(&addr_of(&v));
212212
(**repr).unboxed.fill = new_len * sys::size_of::<T>();
213213
}
214214

215215
#[inline(always)]
216-
pub unsafe fn push<T>(v: &mut @[const T], initval: T) {
216+
pub unsafe fn push<T>(v: &mut @[T], initval: T) {
217217
let repr: **VecRepr = ::cast::reinterpret_cast(&v);
218218
let fill = (**repr).unboxed.fill;
219219
if (**repr).unboxed.alloc > fill {
@@ -225,7 +225,7 @@ pub mod raw {
225225
}
226226

227227
#[inline(always)] // really pretty please
228-
pub unsafe fn push_fast<T>(v: &mut @[const T], initval: T) {
228+
pub unsafe fn push_fast<T>(v: &mut @[T], initval: T) {
229229
let repr: **VecRepr = ::cast::reinterpret_cast(&v);
230230
let fill = (**repr).unboxed.fill;
231231
(**repr).unboxed.fill += sys::size_of::<T>();
@@ -234,7 +234,7 @@ pub mod raw {
234234
move_val_init(&mut(*p), initval);
235235
}
236236

237-
pub unsafe fn push_slow<T>(v: &mut @[const T], initval: T) {
237+
pub unsafe fn push_slow<T>(v: &mut @[T], initval: T) {
238238
reserve_at_least(&mut *v, v.len() + 1u);
239239
push_fast(v, initval);
240240
}
@@ -250,7 +250,7 @@ pub mod raw {
250250
* * v - A vector
251251
* * n - The number of elements to reserve space for
252252
*/
253-
pub unsafe fn reserve<T>(v: &mut @[const T], n: uint) {
253+
pub unsafe fn reserve<T>(v: &mut @[T], n: uint) {
254254
// Only make the (slow) call into the runtime if we have to
255255
if capacity(*v) < n {
256256
let ptr: **VecRepr = transmute(v);
@@ -274,7 +274,7 @@ pub mod raw {
274274
* * v - A vector
275275
* * n - The number of elements to reserve space for
276276
*/
277-
pub unsafe fn reserve_at_least<T>(v: &mut @[const T], n: uint) {
277+
pub unsafe fn reserve_at_least<T>(v: &mut @[T], n: uint) {
278278
reserve(v, uint::next_power_of_two(n));
279279
}
280280

src/libcore/flate.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static lz_fast : c_int = 0x1; // LZ with only one probe
4646
static lz_norm : c_int = 0x80; // LZ with 128 probes, "normal"
4747
static lz_best : c_int = 0xfff; // LZ with 4095 probes, "best"
4848

49-
pub fn deflate_bytes(bytes: &[const u8]) -> ~[u8] {
49+
pub fn deflate_bytes(bytes: &const [u8]) -> ~[u8] {
5050
do vec::as_const_buf(bytes) |b, len| {
5151
unsafe {
5252
let mut outsz : size_t = 0;
@@ -64,7 +64,7 @@ pub fn deflate_bytes(bytes: &[const u8]) -> ~[u8] {
6464
}
6565
}
6666

67-
pub fn inflate_bytes(bytes: &[const u8]) -> ~[u8] {
67+
pub fn inflate_bytes(bytes: &const [u8]) -> ~[u8] {
6868
do vec::as_const_buf(bytes) |b, len| {
6969
unsafe {
7070
let mut outsz : size_t = 0;

src/libcore/hash.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl<A:Hash> HashUtil for A {
6565

6666
/// Streaming hash-functions should implement this.
6767
pub trait Streaming {
68-
fn input(&self, (&[const u8]));
68+
fn input(&self, (&const [u8]));
6969
// These can be refactored some when we have default methods.
7070
fn result_bytes(&self) -> ~[u8];
7171
fn result_str(&self) -> ~str;
@@ -221,7 +221,7 @@ impl io::Writer for SipState {
221221

222222
// Methods for io::writer
223223
#[inline(always)]
224-
fn write(&self, msg: &[const u8]) {
224+
fn write(&self, msg: &const [u8]) {
225225

226226
let length = msg.len();
227227
self.length += length;
@@ -299,7 +299,7 @@ impl io::Writer for SipState {
299299
impl Streaming for SipState {
300300

301301
#[inline(always)]
302-
fn input(&self, buf: &[const u8]) {
302+
fn input(&self, buf: &const [u8]) {
303303
self.write(buf);
304304
}
305305

src/libcore/io.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ pub enum WriterType { Screen, File }
667667
pub trait Writer {
668668
669669
/// Write all of the given bytes.
670-
fn write(&self, v: &[const u8]);
670+
fn write(&self, v: &const [u8]);
671671
672672
/// Move the current position within the stream. The second parameter
673673
/// determines the position that the first parameter is relative to.
@@ -684,23 +684,23 @@ pub trait Writer {
684684
}
685685
686686
impl Writer for @Writer {
687-
fn write(&self, v: &[const u8]) { self.write(v) }
687+
fn write(&self, v: &const [u8]) { self.write(v) }
688688
fn seek(&self, a: int, b: SeekStyle) { self.seek(a, b) }
689689
fn tell(&self) -> uint { self.tell() }
690690
fn flush(&self) -> int { self.flush() }
691691
fn get_type(&self) -> WriterType { self.get_type() }
692692
}
693693
694694
impl<W:Writer,C> Writer for Wrapper<W, C> {
695-
fn write(&self, bs: &[const u8]) { self.base.write(bs); }
695+
fn write(&self, bs: &const [u8]) { self.base.write(bs); }
696696
fn seek(&self, off: int, style: SeekStyle) { self.base.seek(off, style); }
697697
fn tell(&self) -> uint { self.base.tell() }
698698
fn flush(&self) -> int { self.base.flush() }
699699
fn get_type(&self) -> WriterType { File }
700700
}
701701
702702
impl Writer for *libc::FILE {
703-
fn write(&self, v: &[const u8]) {
703+
fn write(&self, v: &const [u8]) {
704704
unsafe {
705705
do vec::as_const_buf(v) |vbuf, len| {
706706
let nout = libc::fwrite(vbuf as *c_void,
@@ -750,7 +750,7 @@ pub fn FILE_writer(f: *libc::FILE, cleanup: bool) -> @Writer {
750750
}
751751

752752
impl Writer for fd_t {
753-
fn write(&self, v: &[const u8]) {
753+
fn write(&self, v: &const [u8]) {
754754
unsafe {
755755
let mut count = 0u;
756756
do vec::as_const_buf(v) |vbuf, len| {
@@ -907,8 +907,10 @@ pub fn u64_to_be_bytes<T>(n: u64, size: uint,
907907
}
908908
}
909909

910-
pub fn u64_from_be_bytes(data: &[const u8],
911-
start: uint, size: uint) -> u64 {
910+
pub fn u64_from_be_bytes(data: &const [u8],
911+
start: uint,
912+
size: uint)
913+
-> u64 {
912914
let mut sz = size;
913915
fail_unless!((sz <= 8u));
914916
let mut val = 0_u64;
@@ -1140,7 +1142,7 @@ pub struct BytesWriter {
11401142
}
11411143
11421144
impl Writer for BytesWriter {
1143-
fn write(&self, v: &[const u8]) {
1145+
fn write(&self, v: &const [u8]) {
11441146
let v_len = v.len();
11451147
let bytes_len = vec::uniq_len(&const self.bytes);
11461148

src/libcore/str.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Section: Creating a string
4444
*
4545
* Fails if invalid UTF-8
4646
*/
47-
pub fn from_bytes(vv: &[const u8]) -> ~str {
47+
pub fn from_bytes(vv: &const [u8]) -> ~str {
4848
fail_unless!(is_utf8(vv));
4949
return unsafe { raw::from_bytes(vv) };
5050
}
@@ -1574,7 +1574,7 @@ Section: Misc
15741574
*/
15751575

15761576
/// Determines if a vector of bytes contains valid UTF-8
1577-
pub fn is_utf8(v: &[const u8]) -> bool {
1577+
pub fn is_utf8(v: &const [u8]) -> bool {
15781578
let mut i = 0u;
15791579
let total = vec::len::<u8>(v);
15801580
while i < total {
@@ -2131,7 +2131,7 @@ pub mod raw {
21312131
}
21322132

21332133
/// Converts a vector of bytes to a string.
2134-
pub unsafe fn from_bytes(v: &[const u8]) -> ~str {
2134+
pub unsafe fn from_bytes(v: &const [u8]) -> ~str {
21352135
do vec::as_const_buf(v) |buf, len| {
21362136
from_buf_len(buf, len)
21372137
}

src/libcore/to_bytes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use io::Writer;
1919
use option::{None, Option, Some};
2020
use str;
2121

22-
pub type Cb = &'self fn(buf: &[const u8]) -> bool;
22+
pub type Cb = &'self fn(buf: &const [u8]) -> bool;
2323

2424
/**
2525
* A trait to implement in order to make a type hashable;

0 commit comments

Comments
 (0)