diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index b1c432ec50d..796fc2c802b 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -32,7 +32,7 @@ use std::io; use std::os; use std::str; use std::task; -use std::vec; +use std::slice; use test::MetricMap; @@ -500,7 +500,7 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError], proc_res: &ProcRes) { // true if we found the error in question - let mut found_flags = vec::from_elem( + let mut found_flags = slice::from_elem( expected_errors.len(), false); if proc_res.status.success() { diff --git a/src/doc/guide-ffi.md b/src/doc/guide-ffi.md index f043d95b473..ee7c4064dd4 100644 --- a/src/doc/guide-ffi.md +++ b/src/doc/guide-ffi.md @@ -71,7 +71,7 @@ The raw C API needs to be wrapped to provide memory safety and make use of highe like vectors. A library can choose to expose only the safe, high-level interface and hide the unsafe internal details. -Wrapping the functions which expect buffers involves using the `vec::raw` module to manipulate Rust +Wrapping the functions which expect buffers involves using the `slice::raw` module to manipulate Rust vectors as pointers to memory. Rust's vectors are guaranteed to be a contiguous block of memory. The length is number of elements currently contained, and the capacity is the total size in elements of the allocated memory. The length is less than or equal to the capacity. @@ -103,7 +103,7 @@ pub fn compress(src: &[u8]) -> ~[u8] { let psrc = src.as_ptr(); let mut dstlen = snappy_max_compressed_length(srclen); - let mut dst = vec::with_capacity(dstlen as uint); + let mut dst = slice::with_capacity(dstlen as uint); let pdst = dst.as_mut_ptr(); snappy_compress(psrc, srclen, pdst, &mut dstlen); @@ -125,7 +125,7 @@ pub fn uncompress(src: &[u8]) -> Option<~[u8]> { let mut dstlen: size_t = 0; snappy_uncompressed_length(psrc, srclen, &mut dstlen); - let mut dst = vec::with_capacity(dstlen as uint); + let mut dst = slice::with_capacity(dstlen as uint); let pdst = dst.as_mut_ptr(); if snappy_uncompress(psrc, srclen, pdst, &mut dstlen) == 0 { diff --git a/src/doc/guide-tasks.md b/src/doc/guide-tasks.md index 976077f70c8..969ade289d3 100644 --- a/src/doc/guide-tasks.md +++ b/src/doc/guide-tasks.md @@ -255,10 +255,10 @@ might look like the example below. ~~~ # use std::task::spawn; -# use std::vec; +# use std::slice; // Create a vector of ports, one for each child task -let rxs = vec::from_fn(3, |init_val| { +let rxs = slice::from_fn(3, |init_val| { let (tx, rx) = channel(); spawn(proc() { tx.send(some_expensive_computation(init_val)); @@ -304,7 +304,7 @@ be distributed on the available cores. ~~~ # extern crate sync; -# use std::vec; +# use std::slice; fn partial_sum(start: uint) -> f64 { let mut local_sum = 0f64; for num in range(start*100000, (start+1)*100000) { @@ -314,7 +314,7 @@ fn partial_sum(start: uint) -> f64 { } fn main() { - let mut futures = vec::from_fn(1000, |ind| sync::Future::spawn( proc() { partial_sum(ind) })); + let mut futures = slice::from_fn(1000, |ind| sync::Future::spawn( proc() { partial_sum(ind) })); let mut final_res = 0f64; for ft in futures.mut_iter() { @@ -342,7 +342,7 @@ a single large vector of floats. Each task needs the full vector to perform its extern crate rand; extern crate sync; -use std::vec; +use std::slice; use sync::Arc; fn pnorm(nums: &~[f64], p: uint) -> f64 { @@ -350,7 +350,7 @@ fn pnorm(nums: &~[f64], p: uint) -> f64 { } fn main() { - let numbers = vec::from_fn(1000000, |_| rand::random::()); + let numbers = slice::from_fn(1000000, |_| rand::random::()); let numbers_arc = Arc::new(numbers); for num in range(1u, 10) { @@ -374,9 +374,9 @@ created by the line # extern crate sync; # extern crate rand; # use sync::Arc; -# use std::vec; +# use std::slice; # fn main() { -# let numbers = vec::from_fn(1000000, |_| rand::random::()); +# let numbers = slice::from_fn(1000000, |_| rand::random::()); let numbers_arc=Arc::new(numbers); # } ~~~ @@ -387,9 +387,9 @@ and a clone of it is sent to each task # extern crate sync; # extern crate rand; # use sync::Arc; -# use std::vec; +# use std::slice; # fn main() { -# let numbers=vec::from_fn(1000000, |_| rand::random::()); +# let numbers=slice::from_fn(1000000, |_| rand::random::()); # let numbers_arc = Arc::new(numbers); # let (tx, rx) = channel(); tx.send(numbers_arc.clone()); @@ -404,9 +404,9 @@ Each task recovers the underlying data by # extern crate sync; # extern crate rand; # use sync::Arc; -# use std::vec; +# use std::slice; # fn main() { -# let numbers=vec::from_fn(1000000, |_| rand::random::()); +# let numbers=slice::from_fn(1000000, |_| rand::random::()); # let numbers_arc=Arc::new(numbers); # let (tx, rx) = channel(); # tx.send(numbers_arc.clone()); diff --git a/src/doc/guide-testing.md b/src/doc/guide-testing.md index 1a01fad5da2..3efed4a215b 100644 --- a/src/doc/guide-testing.md +++ b/src/doc/guide-testing.md @@ -188,18 +188,18 @@ For example: # #[allow(unused_imports)]; extern crate test; -use std::vec; +use std::slice; use test::BenchHarness; #[bench] fn bench_sum_1024_ints(b: &mut BenchHarness) { - let v = vec::from_fn(1024, |n| n); + let v = slice::from_fn(1024, |n| n); b.iter(|| {v.iter().fold(0, |old, new| old + *new);} ); } #[bench] fn initialise_a_vector(b: &mut BenchHarness) { - b.iter(|| {vec::from_elem(1024, 0u64);} ); + b.iter(|| {slice::from_elem(1024, 0u64);} ); b.bytes = 1024 * 8; } diff --git a/src/etc/unicode.py b/src/etc/unicode.py index e32954c75d4..1ab705d7ece 100755 --- a/src/etc/unicode.py +++ b/src/etc/unicode.py @@ -162,7 +162,7 @@ def emit_bsearch_range_table(f): f.write(""" fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool { use cmp::{Equal, Less, Greater}; - use vec::ImmutableVector; + use slice::ImmutableVector; use option::None; r.bsearch(|&(lo,hi)| { if lo <= c && c <= hi { Equal } @@ -200,7 +200,7 @@ def emit_conversions_module(f, lowerupper, upperlower): f.write("pub mod conversions {\n") f.write(""" use cmp::{Equal, Less, Greater}; - use vec::ImmutableVector; + use slice::ImmutableVector; use tuple::Tuple2; use option::{Option, Some, None}; @@ -264,7 +264,7 @@ def emit_decomp_module(f, canon, compat, combine): f.write("pub mod decompose {\n"); f.write(" use option::Option;\n"); f.write(" use option::{Some, None};\n"); - f.write(" use vec::ImmutableVector;\n"); + f.write(" use slice::ImmutableVector;\n"); f.write(""" fn bsearch_table(c: char, r: &'static [(char, &'static [char])]) -> Option<&'static [char]> { use cmp::{Equal, Less, Greater}; diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index f2c98b8e5fc..8d6e0386526 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -42,7 +42,7 @@ use std::rc::Rc; use std::rt::global_heap; use std::intrinsics::{TyDesc, get_tydesc}; use std::intrinsics; -use std::vec; +use std::slice; // The way arena uses arrays is really deeply awful. The arrays are // allocated, and have capacities reserved, but the fill for the array @@ -111,7 +111,7 @@ impl Arena { fn chunk(size: uint, is_pod: bool) -> Chunk { Chunk { - data: Rc::new(RefCell::new(vec::with_capacity(size))), + data: Rc::new(RefCell::new(slice::with_capacity(size))), fill: Cell::new(0u), is_pod: Cell::new(is_pod), } diff --git a/src/libcollections/bitv.rs b/src/libcollections/bitv.rs index 87e9c3f238a..7075e47bddf 100644 --- a/src/libcollections/bitv.rs +++ b/src/libcollections/bitv.rs @@ -16,7 +16,7 @@ use std::iter::RandomAccessIterator; use std::iter::{Rev, Enumerate, Repeat, Map, Zip}; use std::ops; use std::uint; -use std::vec; +use std::slice; #[deriving(Clone)] struct SmallBitv { @@ -278,13 +278,13 @@ impl Bitv { let s = if init { if exact { - vec::from_elem(nelems, !0u) + slice::from_elem(nelems, !0u) } else { - let mut v = vec::from_elem(nelems-1, !0u); + let mut v = slice::from_elem(nelems-1, !0u); v.push((1< ~[uint] { - vec::from_fn(self.nbits, |x| self.init_to_vec(x)) + slice::from_fn(self.nbits, |x| self.init_to_vec(x)) } /** @@ -473,7 +473,7 @@ impl Bitv { let len = self.nbits/8 + if self.nbits % 8 == 0 { 0 } else { 1 }; - vec::from_fn(len, |i| + slice::from_fn(len, |i| bit(self, i, 0) | bit(self, i, 1) | bit(self, i, 2) | @@ -489,7 +489,7 @@ impl Bitv { * Transform `self` into a `[bool]` by turning each bit into a `bool`. */ pub fn to_bools(&self) -> ~[bool] { - vec::from_fn(self.nbits, |i| self[i]) + slice::from_fn(self.nbits, |i| self[i]) } /** @@ -879,7 +879,7 @@ impl BitvSet { /// and w1/w2 are the words coming from the two vectors self, other. fn commons<'a>(&'a self, other: &'a BitvSet) -> Map<'static, ((uint, &'a uint), &'a ~[uint]), (uint, uint, uint), - Zip>, Repeat<&'a ~[uint]>>> { + Zip>, Repeat<&'a ~[uint]>>> { let min = cmp::min(self.bitv.storage.len(), other.bitv.storage.len()); self.bitv.storage.slice(0, min).iter().enumerate() .zip(Repeat::new(&other.bitv.storage)) @@ -895,7 +895,7 @@ impl BitvSet { /// `other`. fn outliers<'a>(&'a self, other: &'a BitvSet) -> Map<'static, ((uint, &'a uint), uint), (bool, uint, uint), - Zip>, Repeat>> { + Zip>, Repeat>> { let slen = self.bitv.storage.len(); let olen = other.bitv.storage.len(); @@ -946,7 +946,7 @@ mod tests { use bitv; use std::uint; - use std::vec; + use std::slice; use rand; use rand::Rng; @@ -964,7 +964,7 @@ mod tests { #[test] fn test_0_elements() { let act = Bitv::new(0u, false); - let exp = vec::from_elem::(0u, false); + let exp = slice::from_elem::(0u, false); assert!(act.eq_vec(exp)); } diff --git a/src/libcollections/deque.rs b/src/libcollections/deque.rs index f84354f9b00..05df04d293f 100644 --- a/src/libcollections/deque.rs +++ b/src/libcollections/deque.rs @@ -44,7 +44,7 @@ pub mod bench { extern crate test; use self::test::BenchHarness; use std::container::MutableMap; - use std::vec; + use std::slice; use rand; use rand::Rng; @@ -90,7 +90,7 @@ pub mod bench { bh: &mut BenchHarness) { // setup let mut rng = rand::XorShiftRng::new(); - let mut keys = vec::from_fn(n, |_| rng.gen::() % n); + let mut keys = slice::from_fn(n, |_| rng.gen::() % n); for k in keys.iter() { map.insert(*k, 1); diff --git a/src/libcollections/hashmap.rs b/src/libcollections/hashmap.rs index 46d3ab432cd..ba87e2106e4 100644 --- a/src/libcollections/hashmap.rs +++ b/src/libcollections/hashmap.rs @@ -27,7 +27,7 @@ use std::option::{Option, Some, None}; use rand; use rand::Rng; use std::result::{Ok, Err}; -use std::vec::{ImmutableVector}; +use std::slice::ImmutableVector; mod table { use std::clone::Clone; @@ -1958,7 +1958,7 @@ mod test_map { mod test_set { use super::HashSet; use std::container::Container; - use std::vec::ImmutableEqVector; + use std::slice::ImmutableEqVector; #[test] fn test_disjoint() { diff --git a/src/libcollections/priority_queue.rs b/src/libcollections/priority_queue.rs index 5463d267787..dc9e5a9700d 100644 --- a/src/libcollections/priority_queue.rs +++ b/src/libcollections/priority_queue.rs @@ -14,7 +14,7 @@ use std::clone::Clone; use std::mem::{move_val_init, init, replace, swap}; -use std::vec; +use std::slice; /// A priority queue implemented with a binary heap #[deriving(Clone)] @@ -181,7 +181,7 @@ impl PriorityQueue { /// PriorityQueue iterator pub struct Items <'a, T> { - priv iter: vec::Items<'a, T>, + priv iter: slice::Items<'a, T>, } impl<'a, T> Iterator<&'a T> for Items<'a, T> { diff --git a/src/libcollections/ringbuf.rs b/src/libcollections/ringbuf.rs index e09bf1023d6..e083f3f600f 100644 --- a/src/libcollections/ringbuf.rs +++ b/src/libcollections/ringbuf.rs @@ -14,7 +14,7 @@ //! extra::container::Deque`. use std::cmp; -use std::vec; +use std::slice; use std::iter::{Rev, RandomAccessIterator}; use deque::Deque; @@ -118,7 +118,7 @@ impl RingBuf { /// Create an empty RingBuf with space for at least `n` elements. pub fn with_capacity(n: uint) -> RingBuf { RingBuf{nelts: 0, lo: 0, - elts: vec::from_fn(cmp::max(MINIMUM_CAPACITY, n), |_| None)} + elts: slice::from_fn(cmp::max(MINIMUM_CAPACITY, n), |_| None)} } /// Retrieve an element in the RingBuf by index diff --git a/src/libcollections/smallintmap.rs b/src/libcollections/smallintmap.rs index 603d5bb820d..64be1b92e26 100644 --- a/src/libcollections/smallintmap.rs +++ b/src/libcollections/smallintmap.rs @@ -17,7 +17,7 @@ use std::iter::{Enumerate, FilterMap, Rev}; use std::mem::replace; -use std::vec; +use std::slice; #[allow(missing_doc)] pub struct SmallIntMap { @@ -153,7 +153,7 @@ impl SmallIntMap { /// Empties the hash map, moving all values into the specified closure pub fn move_iter(&mut self) -> FilterMap<(uint, Option), (uint, V), - Enumerate>>> + Enumerate>>> { let values = replace(&mut self.v, ~[]); values.move_iter().enumerate().filter_map(|(i, v)| { @@ -236,7 +236,7 @@ macro_rules! double_ended_iterator { pub struct Entries<'a, T> { priv front: uint, priv back: uint, - priv iter: vec::Items<'a, Option> + priv iter: slice::Items<'a, Option> } iterator!(impl Entries -> (uint, &'a T), get_ref) @@ -246,7 +246,7 @@ pub type RevEntries<'a, T> = Rev>; pub struct MutEntries<'a, T> { priv front: uint, priv back: uint, - priv iter: vec::MutItems<'a, Option> + priv iter: slice::MutItems<'a, Option> } iterator!(impl MutEntries -> (uint, &'a mut T), get_mut_ref) diff --git a/src/libcollections/trie.rs b/src/libcollections/trie.rs index 2232af98eb3..66bcd3cbdda 100644 --- a/src/libcollections/trie.rs +++ b/src/libcollections/trie.rs @@ -13,8 +13,8 @@ use std::mem; use std::uint; use std::mem::init; -use std::vec; -use std::vec::{Items, MutItems}; +use std::slice; +use std::slice::{Items, MutItems}; // FIXME: #5244: need to manually update the TrieNode constructor static SHIFT: uint = 4; @@ -474,7 +474,7 @@ fn remove(count: &mut uint, child: &mut Child, key: uint, /// Forward iterator over a map pub struct Entries<'a, T> { - priv stack: [vec::Items<'a, Child>, .. NUM_CHUNKS], + priv stack: [slice::Items<'a, Child>, .. NUM_CHUNKS], priv length: uint, priv remaining_min: uint, priv remaining_max: uint @@ -483,7 +483,7 @@ pub struct Entries<'a, T> { /// Forward iterator over the key-value pairs of a map, with the /// values being mutable. pub struct MutEntries<'a, T> { - priv stack: [vec::MutItems<'a, Child>, .. NUM_CHUNKS], + priv stack: [slice::MutItems<'a, Child>, .. NUM_CHUNKS], priv length: uint, priv remaining_min: uint, priv remaining_max: uint diff --git a/src/libgetopts/lib.rs b/src/libgetopts/lib.rs index 5abe96b1acc..c25e38fe055 100644 --- a/src/libgetopts/lib.rs +++ b/src/libgetopts/lib.rs @@ -94,7 +94,7 @@ use std::cmp::Eq; use std::result::{Err, Ok}; use std::result; use std::option::{Some, None}; -use std::vec; +use std::slice; /// Name of an option. Either a string or a single char. #[deriving(Clone, Eq)] @@ -525,7 +525,7 @@ pub fn getopts(args: &[~str], optgrps: &[OptGroup]) -> Result { fn f(_x: uint) -> ~[Optval] { return ~[]; } - let mut vals = vec::from_fn(n_opts, f); + let mut vals = slice::from_fn(n_opts, f); let mut free: ~[~str] = ~[]; let l = args.len(); let mut i = 0; diff --git a/src/libgreen/lib.rs b/src/libgreen/lib.rs index 78ea407d4eb..1895717374b 100644 --- a/src/libgreen/lib.rs +++ b/src/libgreen/lib.rs @@ -188,7 +188,7 @@ use std::rt; use std::sync::atomics::{SeqCst, AtomicUint, INIT_ATOMIC_UINT}; use std::sync::deque; use std::task::TaskOpts; -use std::vec; +use std::slice; use std::sync::arc::UnsafeArc; use sched::{Shutdown, Scheduler, SchedHandle, TaskFromFriend, NewNeighbor}; @@ -356,8 +356,8 @@ impl SchedPool { // Create a work queue for each scheduler, ntimes. Create an extra // for the main thread if that flag is set. We won't steal from it. - let arr = vec::from_fn(nscheds, |_| pool.deque_pool.deque()); - let (workers, stealers) = vec::unzip(arr.move_iter()); + let arr = slice::from_fn(nscheds, |_| pool.deque_pool.deque()); + let (workers, stealers) = slice::unzip(arr.move_iter()); pool.stealers = stealers; // Now that we've got all our work queues, create one scheduler per diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs index 3ff7ee390f1..7d635b80dad 100644 --- a/src/liblog/lib.rs +++ b/src/liblog/lib.rs @@ -125,7 +125,7 @@ use std::io; use std::local_data; use std::os; use std::rt; -use std::vec; +use std::slice; use std::vec_ng::Vec; use sync::one::{Once, ONCE_INIT}; @@ -247,7 +247,7 @@ pub fn mod_enabled(level: u32, module: &str) -> bool { } fn enabled(level: u32, module: &str, - iter: vec::Items) -> bool { + iter: slice::Items) -> bool { // Search for the longest match, the vector is assumed to be pre-sorted. for directive in iter.rev() { match directive.name { diff --git a/src/libnative/io/file_unix.rs b/src/libnative/io/file_unix.rs index 1d7938be226..123a0414c9c 100644 --- a/src/libnative/io/file_unix.rs +++ b/src/libnative/io/file_unix.rs @@ -18,7 +18,7 @@ use std::libc::{c_int, c_void}; use std::libc; use std::mem; use std::rt::rtio; -use std::vec; +use std::slice; use std::vec_ng::Vec; use io::{IoResult, retry, keep_going}; @@ -417,7 +417,7 @@ pub fn readlink(p: &CString) -> IoResult { if len == -1 { len = 1024; // FIXME: read PATH_MAX from C ffi? } - let mut buf = vec::with_capacity::(len as uint); + let mut buf = slice::with_capacity::(len as uint); match retry(|| unsafe { libc::readlink(p, buf.as_ptr() as *mut libc::c_char, len as libc::size_t) as libc::c_int diff --git a/src/libnative/io/file_win32.rs b/src/libnative/io/file_win32.rs index c5ae4f00017..28b963ab348 100644 --- a/src/libnative/io/file_win32.rs +++ b/src/libnative/io/file_win32.rs @@ -22,7 +22,7 @@ use std::ptr; use std::rt::rtio; use std::str; use std::sync::arc::UnsafeArc; -use std::vec; +use std::slice; use io::IoResult; @@ -353,8 +353,7 @@ pub fn readdir(p: &CString) -> IoResult<~[Path]> { if fp_buf as uint == 0 { fail!("os::list_dir() failure: got null ptr from wfd"); } else { - let fp_vec = vec::from_buf(fp_buf, - libc::wcslen(fp_buf) as uint); + let fp_vec = slice::from_buf(fp_buf, libc::wcslen(fp_buf) as uint); let fp_trimmed = str::truncate_utf16_at_nul(fp_vec); let fp_str = str::from_utf16(fp_trimmed) .expect("rust_list_dir_wfd_fp_buf returned invalid UTF-16"); diff --git a/src/libnative/io/process.rs b/src/libnative/io/process.rs index 6ac1f2b3692..591c34e9be5 100644 --- a/src/libnative/io/process.rs +++ b/src/libnative/io/process.rs @@ -572,12 +572,12 @@ fn spawn_process_os(config: p::ProcessConfig, #[cfg(unix)] fn with_argv(prog: &str, args: &[~str], cb: |**libc::c_char| -> T) -> T { - use std::vec; + use std::slice; // We can't directly convert `str`s into `*char`s, as someone needs to hold // a reference to the intermediary byte buffers. So first build an array to // hold all the ~[u8] byte strings. - let mut tmps = vec::with_capacity(args.len() + 1); + let mut tmps = slice::with_capacity(args.len() + 1); tmps.push(prog.to_c_str()); @@ -598,14 +598,14 @@ fn with_argv(prog: &str, args: &[~str], cb: |**libc::c_char| -> T) -> T { #[cfg(unix)] fn with_envp(env: Option<~[(~str, ~str)]>, cb: |*c_void| -> T) -> T { - use std::vec; + use std::slice; // On posixy systems we can pass a char** for envp, which is a // null-terminated array of "k=v\n" strings. Like `with_argv`, we have to // have a temporary buffer to hold the intermediary `~[u8]` byte strings. match env { Some(env) => { - let mut tmps = vec::with_capacity(env.len()); + let mut tmps = slice::with_capacity(env.len()); for pair in env.iter() { let kv = format!("{}={}", *pair.ref0(), *pair.ref1()); diff --git a/src/librand/isaac.rs b/src/librand/isaac.rs index b3226d60095..d0dc5b90867 100644 --- a/src/librand/isaac.rs +++ b/src/librand/isaac.rs @@ -12,7 +12,7 @@ use {Rng, SeedableRng, OSRng}; use std::iter::{range_step, Repeat}; -use std::vec::raw; +use std::slice::raw; use std::mem; static RAND_SIZE_LEN: u32 = 8; @@ -431,7 +431,7 @@ impl<'a> SeedableRng<&'a [u64]> for Isaac64Rng { mod test { use super::{IsaacRng, Isaac64Rng}; use {Rng, SeedableRng, OSRng}; - use std::vec; + use std::slice; #[test] fn test_rng_32_rand_seeded() { @@ -491,7 +491,7 @@ mod test { let seed = &[1, 23, 456, 7890, 12345]; let mut ra: IsaacRng = SeedableRng::from_seed(seed); // Regression test that isaac is actually using the above vector - let v = vec::from_fn(10, |_| ra.next_u32()); + let v = slice::from_fn(10, |_| ra.next_u32()); assert_eq!(v, ~[2558573138, 873787463, 263499565, 2103644246, 3595684709, 4203127393, 264982119, 2765226902, 2737944514, 3900253796]); @@ -501,7 +501,7 @@ mod test { // skip forward to the 10000th number for _ in range(0, 10000) { rb.next_u32(); } - let v = vec::from_fn(10, |_| rb.next_u32()); + let v = slice::from_fn(10, |_| rb.next_u32()); assert_eq!(v, ~[3676831399, 3183332890, 2834741178, 3854698763, 2717568474, 1576568959, 3507990155, 179069555, 141456972, 2478885421]); @@ -511,7 +511,7 @@ mod test { let seed = &[1, 23, 456, 7890, 12345]; let mut ra: Isaac64Rng = SeedableRng::from_seed(seed); // Regression test that isaac is actually using the above vector - let v = vec::from_fn(10, |_| ra.next_u64()); + let v = slice::from_fn(10, |_| ra.next_u64()); assert_eq!(v, ~[547121783600835980, 14377643087320773276, 17351601304698403469, 1238879483818134882, 11952566807690396487, 13970131091560099343, @@ -523,7 +523,7 @@ mod test { // skip forward to the 10000th number for _ in range(0, 10000) { rb.next_u64(); } - let v = vec::from_fn(10, |_| rb.next_u64()); + let v = slice::from_fn(10, |_| rb.next_u64()); assert_eq!(v, ~[18143823860592706164, 8491801882678285927, 2699425367717515619, 17196852593171130876, 2606123525235546165, 15790932315217671084, diff --git a/src/librand/lib.rs b/src/librand/lib.rs index dc4e3e50b65..0086b385b79 100644 --- a/src/librand/lib.rs +++ b/src/librand/lib.rs @@ -80,7 +80,7 @@ use std::cast; use std::kinds::marker; use std::local_data; use std::str; -use std::vec; +use std::slice; pub use isaac::{IsaacRng, Isaac64Rng}; pub use os::OSRng; @@ -202,7 +202,7 @@ pub trait Rng { /// println!("{:?}", rng.gen_vec::<(f64, bool)>(5)); /// ``` fn gen_vec(&mut self, len: uint) -> ~[T] { - vec::from_fn(len, |_| self.gen()) + slice::from_fn(len, |_| self.gen()) } /// Generate a random value in the range [`low`, `high`). Fails if @@ -342,7 +342,7 @@ pub trait Rng { /// println!("{:?}", sample); /// ``` fn sample>(&mut self, iter: T, n: uint) -> ~[A] { - let mut reservoir : ~[A] = vec::with_capacity(n); + let mut reservoir : ~[A] = slice::with_capacity(n); for (i, elem) in iter.enumerate() { if i < n { reservoir.push(elem); @@ -677,7 +677,7 @@ pub struct Closed01(F); #[cfg(test)] mod test { - use std::vec; + use std::slice; use super::{Rng, task_rng, random, OSRng, SeedableRng, StdRng}; struct ConstRng { i: u64 } @@ -696,7 +696,7 @@ mod test { let lengths = [0, 1, 2, 3, 4, 5, 6, 7, 80, 81, 82, 83, 84, 85, 86, 87]; for &n in lengths.iter() { - let mut v = vec::from_elem(n, 0u8); + let mut v = slice::from_elem(n, 0u8); r.fill_bytes(v); // use this to get nicer error messages. diff --git a/src/librustc/back/rpath.rs b/src/librustc/back/rpath.rs index d8feb0a47b3..1d5448cea04 100644 --- a/src/librustc/back/rpath.rs +++ b/src/librustc/back/rpath.rs @@ -14,7 +14,7 @@ use metadata::cstore; use metadata::filesearch; use collections::HashSet; -use std::{os, vec}; +use std::{os, slice}; use std::vec_ng::Vec; use syntax::abi; @@ -46,7 +46,7 @@ pub fn get_rpath_flags(sess: &Session, out_filename: &Path) -> Vec<~str> { let libs = libs.move_iter().filter_map(|(_, l)| l.map(|p| p.clone())).collect(); // We don't currently rpath extern libraries, but we know // where rustrt is and we know every rust program needs it - let libs = vec::append_one(libs, get_sysroot_absolute_rt_lib(sess)); + let libs = slice::append_one(libs, get_sysroot_absolute_rt_lib(sess)); let rpaths = get_rpaths(os, sysroot, output, libs, sess.opts.target_triple); diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs index 6d8029b1638..27aba271127 100644 --- a/src/librustc/front/test.rs +++ b/src/librustc/front/test.rs @@ -19,7 +19,7 @@ use front::std_inject::with_version; use metadata::creader::Loader; use std::cell::RefCell; -use std::vec; +use std::slice; use std::vec_ng::Vec; use std::vec_ng; use syntax::ast_util::*; diff --git a/src/librustc/metadata/loader.rs b/src/librustc/metadata/loader.rs index 28556105c7b..1181f0d0928 100644 --- a/src/librustc/metadata/loader.rs +++ b/src/librustc/metadata/loader.rs @@ -30,7 +30,7 @@ use std::cmp; use std::io; use std::os::consts::{macos, freebsd, linux, android, win32}; use std::str; -use std::vec; +use std::slice; use std::vec_ng::Vec; use collections::{HashMap, HashSet}; @@ -443,7 +443,7 @@ fn get_metadata_section_imp(os: Os, filename: &Path) -> Result Result DataFlowContext<'a, O> { changed: true }; - let mut temp = vec::from_elem(self.words_per_id, 0u); + let mut temp = slice::from_elem(self.words_per_id, 0u); let mut loop_scopes = Vec::new(); while propcx.changed { diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index 2ce34a31129..3b322d02787 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -32,7 +32,7 @@ use syntax::visit; use collections::HashMap; use std::iter::Enumerate; -use std::vec; +use std::slice; use std::vec_ng::Vec; // The actual lang items defined come at the end of this file in one handy table. @@ -60,7 +60,7 @@ impl LanguageItems { } } - pub fn items<'a>(&'a self) -> Enumerate>> { + pub fn items<'a>(&'a self) -> Enumerate>> { self.items.iter().enumerate() } diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index 61a855a7f09..c29f1082a11 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -16,7 +16,7 @@ * closure. */ -use std::vec; +use std::slice; use back::abi; use driver::session; @@ -230,7 +230,7 @@ fn resolve_default_method_vtables(bcx: &Block, vtables.len() - num_method_vtables; vtables.tailn(num_impl_type_parameters).to_owned() }, - None => vec::from_elem(num_method_vtables, @Vec::new()) + None => slice::from_elem(num_method_vtables, @Vec::new()) }; let param_vtables = @(vec_ng::append((*trait_vtables_fixed).clone(), diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index 390c40c0a75..61d6cac5250 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -33,7 +33,7 @@ use util::ppaux::{Repr, ty_to_str}; use std::c_str::ToCStr; use std::libc::c_uint; -use std::vec; +use std::slice; use std::vec_ng::Vec; use std::vec_ng; use syntax::{ast, ast_util}; @@ -95,7 +95,7 @@ fn const_vec(cx: &CrateContext, e: &ast::Expr, let vec_ty = ty::expr_ty(cx.tcx(), e); let unit_ty = ty::sequence_element_type(cx.tcx(), vec_ty); let llunitty = type_of::type_of(cx, unit_ty); - let (vs, inlineable) = vec::unzip(es.iter().map(|e| const_expr(cx, *e, is_local))); + let (vs, inlineable) = slice::unzip(es.iter().map(|e| const_expr(cx, *e, is_local))); // If the vector contains enums, an LLVM array won't work. let v = if vs.iter().any(|vi| val_ty(*vi) != llunitty) { C_struct(cx, vs, false) @@ -563,7 +563,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr, } } }).to_owned_vec(); - let (cs, inlineable) = vec::unzip(cs.move_iter()); + let (cs, inlineable) = slice::unzip(cs.move_iter()); (adt::trans_const(cx, repr, discr, cs), inlineable.iter().fold(true, |a, &b| a && b)) }) @@ -612,7 +612,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr, const_eval::const_uint(i) => i as uint, _ => cx.sess().span_bug(count.span, "count must be integral const expression.") }; - let vs = vec::from_elem(n, const_expr(cx, elem, is_local).val0()); + let vs = slice::from_elem(n, const_expr(cx, elem, is_local).val0()); let v = if vs.iter().any(|vi| val_ty(*vi) != llunitty) { C_struct(cx, vs, false) } else { diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index f87ce57089a..d507d6d2db4 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -148,7 +148,7 @@ use collections::HashSet; use std::libc::{c_uint, c_ulonglong, c_longlong}; use std::ptr; use std::sync::atomics; -use std::vec; +use std::slice; use std::vec_ng::Vec; use syntax::codemap::{Span, Pos}; use syntax::{abi, ast, codemap, ast_util, ast_map, opt_vec}; @@ -709,7 +709,7 @@ pub fn create_function_debug_context(cx: &CrateContext, return create_DIArray(DIB(cx), []); } - let mut signature = vec::with_capacity(fn_decl.inputs.len() + 1); + let mut signature = slice::with_capacity(fn_decl.inputs.len() + 1); // Return type -- llvm::DIBuilder wants this at index 0 match fn_decl.output.node { diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index a38322ef0dc..6e74b82f85c 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -70,7 +70,7 @@ use util::nodemap::NodeMap; use middle::trans::machine::llsize_of; use middle::trans::type_::Type; -use std::vec; +use std::slice; use std::vec_ng::Vec; use syntax::ast; use syntax::codemap; @@ -1010,7 +1010,7 @@ fn trans_rec_or_struct<'a>( let ty = node_id_type(bcx, id); let tcx = bcx.tcx(); with_field_tys(tcx, ty, Some(id), |discr, field_tys| { - let mut need_base = vec::from_elem(field_tys.len(), true); + let mut need_base = slice::from_elem(field_tys.len(), true); let numbered_fields = fields.map(|field| { let opt_pos = diff --git a/src/librustc/middle/trans/type_.rs b/src/librustc/middle/trans/type_.rs index bd1a7498d21..cf64e6048b3 100644 --- a/src/librustc/middle/trans/type_.rs +++ b/src/librustc/middle/trans/type_.rs @@ -20,7 +20,7 @@ use syntax::abi::{X86, X86_64, Arm, Mips}; use std::c_str::ToCStr; use std::cast; -use std::vec; +use std::slice; use std::vec_ng::Vec; use std::libc::{c_uint}; @@ -263,7 +263,7 @@ impl Type { pub fn get_field(&self, idx: uint) -> Type { unsafe { let num_fields = llvm::LLVMCountStructElementTypes(self.to_ref()) as uint; - let mut elems = vec::from_elem(num_fields, 0 as TypeRef); + let mut elems = slice::from_elem(num_fields, 0 as TypeRef); llvm::LLVMGetStructElementTypes(self.to_ref(), elems.as_mut_ptr()); diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 8ed28711194..4cf8f139d5a 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -118,7 +118,7 @@ use std::cell::{Cell, RefCell}; use collections::HashMap; use std::mem::replace; use std::result; -use std::vec; +use std::slice; use std::vec_ng::Vec; use std::vec_ng; use syntax::abi::AbiSet; @@ -3978,7 +3978,7 @@ pub fn check_bounds_are_used(ccx: &CrateCtxt, // make a vector of booleans initially false, set to true when used if tps.len() == 0u { return; } - let mut tps_used = vec::from_elem(tps.len(), false); + let mut tps_used = slice::from_elem(tps.len(), false); ty::walk_ty(ty, |t| { match ty::get(t).sty { diff --git a/src/librustc/middle/typeck/infer/region_inference/mod.rs b/src/librustc/middle/typeck/infer/region_inference/mod.rs index 415367eea62..4e570edcaef 100644 --- a/src/librustc/middle/typeck/infer/region_inference/mod.rs +++ b/src/librustc/middle/typeck/infer/region_inference/mod.rs @@ -26,7 +26,7 @@ use util::ppaux::{Repr}; use std::cell::{Cell, RefCell}; use std::uint; -use std::vec; +use std::slice; use std::vec_ng::Vec; use collections::{HashMap, HashSet}; use syntax::ast; @@ -1049,7 +1049,7 @@ impl<'a> RegionVarBindings<'a> { // idea is to report errors that derive from independent // regions of the graph, but not those that derive from // overlapping locations. - let mut dup_vec = vec::from_elem(self.num_vars(), uint::MAX); + let mut dup_vec = slice::from_elem(self.num_vars(), uint::MAX); let mut opt_graph = None; diff --git a/src/librustc/util/sha2.rs b/src/librustc/util/sha2.rs index 5dbebbb4db1..8518b11ecf1 100644 --- a/src/librustc/util/sha2.rs +++ b/src/librustc/util/sha2.rs @@ -14,7 +14,7 @@ use std::iter::range_step; use std::num::Zero; -use std::vec::bytes::{MutableByteVector, copy_memory}; +use std::slice::bytes::{MutableByteVector, copy_memory}; use std::vec_ng::Vec; use serialize::hex::ToHex; @@ -528,7 +528,7 @@ mod tests { use super::{Digest, Sha256, FixedBuffer}; use std::num::Bounded; - use std::vec; + use std::slice; use std::vec_ng::Vec; use self::rand::isaac::IsaacRng; use self::rand::Rng; @@ -604,7 +604,7 @@ mod tests { /// correct. fn test_digest_1million_random(digest: &mut D, blocksize: uint, expected: &str) { let total_size = 1000000; - let buffer = vec::from_elem(blocksize * 2, 'a' as u8); + let buffer = slice::from_elem(blocksize * 2, 'a' as u8); let mut rng = IsaacRng::new_unseeded(); let mut count = 0; diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 8780b16918b..a045d042dcd 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -33,7 +33,7 @@ use std::libc; use std::local_data; use std::mem; use std::str; -use std::vec; +use std::slice; use collections::HashMap; use html::toc::TocBuilder; @@ -130,7 +130,7 @@ pub fn render(w: &mut io::Writer, s: &str, print_toc: bool) -> fmt::Result { extern fn block(ob: *buf, text: *buf, lang: *buf, opaque: *libc::c_void) { unsafe { let my_opaque: &my_opaque = cast::transmute(opaque); - vec::raw::buf_as_slice((*text).data, (*text).size as uint, |text| { + slice::raw::buf_as_slice((*text).data, (*text).size as uint, |text| { let text = str::from_utf8(text).unwrap(); let mut lines = text.lines().filter(|l| stripped_filtered_line(*l).is_none()); let text = lines.to_owned_vec().connect("\n"); @@ -144,7 +144,7 @@ pub fn render(w: &mut io::Writer, s: &str, print_toc: bool) -> fmt::Result { let rendered = if lang.is_null() { false } else { - vec::raw::buf_as_slice((*lang).data, + slice::raw::buf_as_slice((*lang).data, (*lang).size as uint, |rlang| { let rlang = str::from_utf8(rlang).unwrap(); if rlang.contains("notrust") { @@ -255,7 +255,7 @@ pub fn render(w: &mut io::Writer, s: &str, print_toc: bool) -> fmt::Result { }; if ret.is_ok() { - ret = vec::raw::buf_as_slice((*ob).data, (*ob).size as uint, |buf| { + ret = slice::raw::buf_as_slice((*ob).data, (*ob).size as uint, |buf| { w.write(buf) }); } @@ -271,7 +271,7 @@ pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector) { let (should_fail, no_run, ignore) = if lang.is_null() { (false, false, false) } else { - vec::raw::buf_as_slice((*lang).data, + slice::raw::buf_as_slice((*lang).data, (*lang).size as uint, |lang| { let s = str::from_utf8(lang).unwrap(); (s.contains("should_fail"), @@ -280,7 +280,7 @@ pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector) { }) }; if ignore { return } - vec::raw::buf_as_slice((*text).data, (*text).size as uint, |text| { + slice::raw::buf_as_slice((*text).data, (*text).size as uint, |text| { let tests = &mut *(opaque as *mut ::test::Collector); let text = str::from_utf8(text).unwrap(); let mut lines = text.lines().map(|l| stripped_filtered_line(l).unwrap_or(l)); @@ -295,7 +295,7 @@ pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector) { if text.is_null() { tests.register_header("", level as u32); } else { - vec::raw::buf_as_slice((*text).data, (*text).size as uint, |text| { + slice::raw::buf_as_slice((*text).data, (*text).size as uint, |text| { let text = str::from_utf8(text).unwrap(); tests.register_header(text, level as u32); }) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 26723482595..c77c666e3c0 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -38,7 +38,7 @@ use std::local_data; use std::io; use std::io::{fs, File, BufferedWriter, MemWriter, BufferedReader}; use std::str; -use std::vec; +use std::slice; use std::vec_ng::Vec; use collections::{HashMap, HashSet}; @@ -1026,7 +1026,7 @@ fn item_module(w: &mut Writer, cx: &Context, item: &clean::Item, items: &[clean::Item]) -> fmt::Result { try!(document(w, item)); debug!("{:?}", items); - let mut indices = vec::from_fn(items.len(), |i| i); + let mut indices = slice::from_fn(items.len(), |i| i); fn cmp(i1: &clean::Item, i2: &clean::Item, idx1: uint, idx2: uint) -> Ordering { if shortty(i1) == shortty(i2) { diff --git a/src/librustuv/file.rs b/src/librustuv/file.rs index e66452041a5..45e7ba4d21f 100644 --- a/src/librustuv/file.rs +++ b/src/librustuv/file.rs @@ -448,7 +448,7 @@ mod test { use std::libc::{O_CREAT, O_RDWR, O_RDONLY, S_IWUSR, S_IRUSR}; use std::io; use std::str; - use std::vec; + use std::slice; use super::FsRequest; use super::super::Loop; use super::super::local_loop; @@ -484,7 +484,7 @@ mod test { let fd = result.fd; // read - let mut read_mem = vec::from_elem(1000, 0u8); + let mut read_mem = slice::from_elem(1000, 0u8); let result = FsRequest::read(l(), fd, read_mem, 0); assert!(result.is_ok()); diff --git a/src/librustuv/process.rs b/src/librustuv/process.rs index 8a6b4d3150e..bd07bf18a72 100644 --- a/src/librustuv/process.rs +++ b/src/librustuv/process.rs @@ -15,7 +15,7 @@ use std::libc; use std::ptr; use std::rt::rtio::RtioProcess; use std::rt::task::BlockedTask; -use std::vec; +use std::slice; use homing::{HomingIO, HomeHandle}; use pipe::PipeWatcher; @@ -48,8 +48,8 @@ impl Process { for slot in config.extra_io.iter() { io.push(*slot); } - let mut stdio = vec::with_capacity::(io.len()); - let mut ret_io = vec::with_capacity(io.len()); + let mut stdio = slice::with_capacity::(io.len()); + let mut ret_io = slice::with_capacity(io.len()); unsafe { stdio.set_len(io.len()); for (slot, other) in stdio.iter().zip(io.iter()) { @@ -167,14 +167,14 @@ unsafe fn set_stdio(dst: *uvll::uv_stdio_container_t, fn with_argv(prog: &str, args: &[~str], f: |**libc::c_char| -> T) -> T { // First, allocation space to put all the C-strings (we need to have // ownership of them somewhere - let mut c_strs = vec::with_capacity(args.len() + 1); + let mut c_strs = slice::with_capacity(args.len() + 1); c_strs.push(prog.to_c_str()); for arg in args.iter() { c_strs.push(arg.to_c_str()); } // Next, create the char** array - let mut c_args = vec::with_capacity(c_strs.len() + 1); + let mut c_args = slice::with_capacity(c_strs.len() + 1); for s in c_strs.iter() { c_args.push(s.with_ref(|p| p)); } @@ -189,11 +189,11 @@ fn with_env(env: Option<&[(~str, ~str)]>, f: |**libc::c_char| -> T) -> T { None => { return f(ptr::null()); } }; // As with argv, create some temporary storage and then the actual array - let mut envp = vec::with_capacity(env.len()); + let mut envp = slice::with_capacity(env.len()); for &(ref key, ref value) in env.iter() { envp.push(format!("{}={}", *key, *value).to_c_str()); } - let mut c_envp = vec::with_capacity(envp.len() + 1); + let mut c_envp = slice::with_capacity(envp.len() + 1); for s in envp.iter() { c_envp.push(s.with_ref(|p| p)); } diff --git a/src/libserialize/base64.rs b/src/libserialize/base64.rs index a09b03ec58a..62e078e26c1 100644 --- a/src/libserialize/base64.rs +++ b/src/libserialize/base64.rs @@ -337,11 +337,11 @@ mod tests { #[test] fn test_base64_random() { use self::rand::{task_rng, random, Rng}; - use std::vec; + use std::slice; for _ in range(0, 1000) { let times = task_rng().gen_range(1u, 100); - let v = vec::from_fn(times, |_| random::()); + let v = slice::from_fn(times, |_| random::()); assert_eq!(v.to_base64(STANDARD).from_base64().unwrap(), v); } } diff --git a/src/libserialize/ebml.rs b/src/libserialize/ebml.rs index bc9eee51753..2b416f263c2 100644 --- a/src/libserialize/ebml.rs +++ b/src/libserialize/ebml.rs @@ -1041,8 +1041,8 @@ mod bench { #[bench] pub fn vuint_at_A_aligned(bh: &mut BenchHarness) { - use std::vec; - let data = vec::from_fn(4*100, |i| { + use std::slice; + let data = slice::from_fn(4*100, |i| { match i % 2 { 0 => 0x80u8, _ => i as u8, @@ -1060,8 +1060,8 @@ mod bench { #[bench] pub fn vuint_at_A_unaligned(bh: &mut BenchHarness) { - use std::vec; - let data = vec::from_fn(4*100+1, |i| { + use std::slice; + let data = slice::from_fn(4*100+1, |i| { match i % 2 { 1 => 0x80u8, _ => i as u8 @@ -1079,8 +1079,8 @@ mod bench { #[bench] pub fn vuint_at_D_aligned(bh: &mut BenchHarness) { - use std::vec; - let data = vec::from_fn(4*100, |i| { + use std::slice; + let data = slice::from_fn(4*100, |i| { match i % 4 { 0 => 0x10u8, 3 => i as u8, @@ -1099,8 +1099,8 @@ mod bench { #[bench] pub fn vuint_at_D_unaligned(bh: &mut BenchHarness) { - use std::vec; - let data = vec::from_fn(4*100+1, |i| { + use std::slice; + let data = slice::from_fn(4*100+1, |i| { match i % 4 { 1 => 0x10u8, 0 => i as u8, diff --git a/src/libserialize/hex.rs b/src/libserialize/hex.rs index 5ec70773c3f..a95c77c7c13 100644 --- a/src/libserialize/hex.rs +++ b/src/libserialize/hex.rs @@ -10,7 +10,7 @@ //! Hex binary-to-text encoding use std::str; -use std::vec; +use std::slice; use std::fmt; /// A trait for converting a value to hexadecimal encoding @@ -39,7 +39,7 @@ impl<'a> ToHex for &'a [u8] { * ``` */ fn to_hex(&self) -> ~str { - let mut v = vec::with_capacity(self.len() * 2); + let mut v = slice::with_capacity(self.len() * 2); for &byte in self.iter() { v.push(CHARS[byte >> 4]); v.push(CHARS[byte & 0xf]); @@ -106,7 +106,7 @@ impl<'a> FromHex for &'a str { */ fn from_hex(&self) -> Result<~[u8], FromHexError> { // This may be an overestimate if there is any whitespace - let mut b = vec::with_capacity(self.len() / 2); + let mut b = slice::with_capacity(self.len() / 2); let mut modulus = 0; let mut buf = 0u8; diff --git a/src/libserialize/serialize.rs b/src/libserialize/serialize.rs index fd57f47e881..a103d0f4964 100644 --- a/src/libserialize/serialize.rs +++ b/src/libserialize/serialize.rs @@ -16,7 +16,7 @@ Core encoding and decoding interfaces. use std::path; use std::rc::Rc; -use std::vec; +use std::slice; use std::vec_ng::Vec; pub trait Encoder { @@ -428,7 +428,7 @@ impl> Encodable for ~[T] { impl> Decodable for ~[T] { fn decode(d: &mut D) -> ~[T] { d.read_seq(|d, len| { - vec::from_fn(len, |i| { + slice::from_fn(len, |i| { d.read_seq_elt(i, |d| Decodable::decode(d)) }) }) @@ -680,7 +680,7 @@ pub trait DecoderHelpers { impl DecoderHelpers for D { fn read_to_vec(&mut self, f: |&mut D| -> T) -> ~[T] { self.read_seq(|this, len| { - vec::from_fn(len, |i| { + slice::from_fn(len, |i| { this.read_seq_elt(i, |this| f(this)) }) }) diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index 3ca08797dd1..33638fffc6d 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -19,7 +19,7 @@ use container::Container; use cast; use fmt; use iter::Iterator; -use vec::{ImmutableVector, MutableVector, Vector}; +use slice::{ImmutableVector, MutableVector, Vector}; use vec_ng::Vec; use option::{Option, Some, None}; diff --git a/src/libstd/c_str.rs b/src/libstd/c_str.rs index af5d9838186..96c7c218127 100644 --- a/src/libstd/c_str.rs +++ b/src/libstd/c_str.rs @@ -76,8 +76,8 @@ use ptr::RawPtr; use ptr; use str::StrSlice; use str; -use vec::{ImmutableVector, MutableVector}; -use vec; +use slice::{ImmutableVector, MutableVector}; +use slice; use rt::global_heap::malloc_raw; use raw::Slice; @@ -343,7 +343,7 @@ impl<'a> ToCStr for &'a [u8] { unsafe fn with_c_str(v: &[u8], checked: bool, f: |*libc::c_char| -> T) -> T { if v.len() < BUF_LEN { let mut buf: [u8, .. BUF_LEN] = mem::uninit(); - vec::bytes::copy_memory(buf, v); + slice::bytes::copy_memory(buf, v); buf[v.len()] = 0; let buf = buf.as_mut_ptr(); diff --git a/src/libstd/comm/shared.rs b/src/libstd/comm/shared.rs index 328dd70223b..8c8ae85e4ea 100644 --- a/src/libstd/comm/shared.rs +++ b/src/libstd/comm/shared.rs @@ -30,7 +30,7 @@ use rt::task::{Task, BlockedTask}; use rt::thread::Thread; use sync::atomics; use unstable::mutex::NativeMutex; -use vec::OwnedVector; +use slice::OwnedVector; use mpsc = sync::mpsc_queue; diff --git a/src/libstd/comm/stream.rs b/src/libstd/comm/stream.rs index d386e97d5bf..5820b13a35f 100644 --- a/src/libstd/comm/stream.rs +++ b/src/libstd/comm/stream.rs @@ -30,7 +30,7 @@ use rt::task::{Task, BlockedTask}; use rt::thread::Thread; use spsc = sync::spsc_queue; use sync::atomics; -use vec::OwnedVector; +use slice::OwnedVector; static DISCONNECTED: int = int::MIN; #[cfg(test)] diff --git a/src/libstd/fmt/mod.rs b/src/libstd/fmt/mod.rs index 67e2fc00b8b..d3ceba025ea 100644 --- a/src/libstd/fmt/mod.rs +++ b/src/libstd/fmt/mod.rs @@ -490,8 +490,8 @@ use repr; use result::{Ok, Err}; use str::StrSlice; use str; -use vec::ImmutableVector; -use vec; +use slice::ImmutableVector; +use slice; pub use self::num::radix; pub use self::num::Radix; @@ -520,7 +520,7 @@ pub struct Formatter<'a> { /// Output buffer. buf: &'a mut io::Writer, - priv curarg: vec::Items<'a, Argument<'a>>, + priv curarg: slice::Items<'a, Argument<'a>>, priv args: &'a [Argument<'a>], } diff --git a/src/libstd/fmt/num.rs b/src/libstd/fmt/num.rs index 681d0678ed4..4b35a7596c9 100644 --- a/src/libstd/fmt/num.rs +++ b/src/libstd/fmt/num.rs @@ -17,7 +17,7 @@ use fmt; use iter::{Iterator, DoubleEndedIterator}; use num::{Int, cast, zero}; use option::{Some, None}; -use vec::{ImmutableVector, MutableVector}; +use slice::{ImmutableVector, MutableVector}; /// A type that represents a specific radix trait GenericRadix { diff --git a/src/libstd/hash/mod.rs b/src/libstd/hash/mod.rs index dd40f600873..d329c15a7d7 100644 --- a/src/libstd/hash/mod.rs +++ b/src/libstd/hash/mod.rs @@ -70,7 +70,7 @@ use ops::Deref; use option::{Option, Some, None}; use rc::Rc; use str::{Str, StrSlice}; -use vec::{Vector, ImmutableVector}; +use slice::{Vector, ImmutableVector}; use vec_ng::Vec; /// Reexport the `sip::hash` function as our default hasher. @@ -293,7 +293,7 @@ mod tests { use iter::{Iterator}; use option::{Some, None}; use result::Ok; - use vec::ImmutableVector; + use slice::ImmutableVector; use super::{Hash, Hasher}; diff --git a/src/libstd/hash/sip.rs b/src/libstd/hash/sip.rs index d1d4d4c90f9..d448f4eeb37 100644 --- a/src/libstd/hash/sip.rs +++ b/src/libstd/hash/sip.rs @@ -30,7 +30,7 @@ use default::Default; use io::{IoResult, Writer}; use iter::Iterator; use result::Ok; -use vec::ImmutableVector; +use slice::ImmutableVector; use super::{Hash, Hasher}; @@ -292,7 +292,7 @@ mod tests { use num::ToStrRadix; use option::{Some, None}; use str::{Str, OwnedStr}; - use vec::{Vector, ImmutableVector, OwnedVector}; + use slice::{Vector, ImmutableVector, OwnedVector}; use self::test::BenchHarness; use super::super::Hash; diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 3ae44e4a1b5..ab9a8377136 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -17,8 +17,8 @@ use iter::ExactSize; use ops::Drop; use option::{Some, None, Option}; use result::{Ok, Err}; -use vec::{OwnedVector, ImmutableVector, MutableVector}; -use vec; +use slice::{OwnedVector, ImmutableVector, MutableVector}; +use slice; /// Wraps a Reader and buffers input from it /// @@ -58,7 +58,7 @@ impl BufferedReader { // everything up-front. This allows creation of BufferedReader instances // to be very cheap (large mallocs are not nearly as expensive as large // callocs). - let mut buf = vec::with_capacity(cap); + let mut buf = slice::with_capacity(cap); unsafe { buf.set_len(cap); } BufferedReader { inner: inner, @@ -106,7 +106,7 @@ impl Reader for BufferedReader { let nread = { let available = try!(self.fill()); let nread = cmp::min(available.len(), buf.len()); - vec::bytes::copy_memory(buf, available.slice_to(nread)); + slice::bytes::copy_memory(buf, available.slice_to(nread)); nread }; self.pos += nread; @@ -140,7 +140,7 @@ impl BufferedWriter { /// Creates a new `BufferedWriter` with the specified buffer capacity pub fn with_capacity(cap: uint, inner: W) -> BufferedWriter { // See comments in BufferedReader for why this uses unsafe code. - let mut buf = vec::with_capacity(cap); + let mut buf = slice::with_capacity(cap); unsafe { buf.set_len(cap); } BufferedWriter { inner: Some(inner), @@ -190,7 +190,7 @@ impl Writer for BufferedWriter { self.inner.get_mut_ref().write(buf) } else { let dst = self.buf.mut_slice_from(self.pos); - vec::bytes::copy_memory(dst, buf); + slice::bytes::copy_memory(dst, buf); self.pos += buf.len(); Ok(()) } diff --git a/src/libstd/io/comm_adapters.rs b/src/libstd/io/comm_adapters.rs index f09555e93a0..075c65e04be 100644 --- a/src/libstd/io/comm_adapters.rs +++ b/src/libstd/io/comm_adapters.rs @@ -16,7 +16,7 @@ use io; use option::{None, Option, Some}; use result::{Ok, Err}; use super::{Reader, Writer, IoResult}; -use vec::{bytes, CloneableVector, MutableVector, ImmutableVector}; +use slice::{bytes, CloneableVector, MutableVector, ImmutableVector}; /// Allows reading from a rx. /// diff --git a/src/libstd/io/extensions.rs b/src/libstd/io/extensions.rs index f7cab755714..070cbd569e6 100644 --- a/src/libstd/io/extensions.rs +++ b/src/libstd/io/extensions.rs @@ -21,7 +21,7 @@ use option::{Option, Some, None}; use result::{Ok, Err}; use io; use io::{IoError, IoResult, Reader}; -use vec::{OwnedVector, ImmutableVector}; +use slice::{OwnedVector, ImmutableVector}; use ptr::RawPtr; /// An iterator that reads a single byte on each iteration, @@ -114,7 +114,7 @@ pub fn u64_from_be_bytes(data: &[u8], -> u64 { use ptr::{copy_nonoverlapping_memory}; use mem::from_be64; - use vec::MutableVector; + use slice::MutableVector; assert!(size <= 8u); @@ -470,10 +470,10 @@ mod bench { macro_rules! u64_from_be_bytes_bench_impl( ($size:expr, $stride:expr, $start_index:expr) => ({ - use vec; + use slice; use super::u64_from_be_bytes; - let data = vec::from_fn($stride*100+$start_index, |i| i as u8); + let data = slice::from_fn($stride*100+$start_index, |i| i as u8); let mut sum = 0u64; bh.iter(|| { let mut i = $start_index; diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs index 3435c9a07aa..aab2f8c887c 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -62,7 +62,7 @@ use option::{Some, None, Option}; use result::{Ok, Err}; use path; use path::{Path, GenericPath}; -use vec::{OwnedVector, ImmutableVector}; +use slice::{OwnedVector, ImmutableVector}; use vec_ng::Vec; /// Unconstrained file access type that exposes read and write operations diff --git a/src/libstd/io/mem.rs b/src/libstd/io/mem.rs index 3e79225f9ab..d0c4ef308b3 100644 --- a/src/libstd/io/mem.rs +++ b/src/libstd/io/mem.rs @@ -16,8 +16,8 @@ use option::None; use result::{Err, Ok}; use io; use io::{Reader, Writer, Seek, Buffer, IoError, SeekStyle, IoResult}; -use vec; -use vec::{Vector, ImmutableVector, MutableVector, OwnedCloneableVector}; +use slice; +use slice::{Vector, ImmutableVector, MutableVector, OwnedCloneableVector}; fn combine(seek: SeekStyle, cur: uint, end: uint, offset: i64) -> IoResult { // compute offset as signed and clamp to prevent overflow @@ -64,7 +64,7 @@ impl MemWriter { /// Create a new `MemWriter`, allocating at least `n` bytes for /// the internal buffer. pub fn with_capacity(n: uint) -> MemWriter { - MemWriter { buf: vec::with_capacity(n), pos: 0 } + MemWriter { buf: slice::with_capacity(n), pos: 0 } } /// Acquires an immutable reference to the underlying buffer of this @@ -98,7 +98,7 @@ impl Writer for MemWriter { // Do the necessary writes if left.len() > 0 { - vec::bytes::copy_memory(self.buf.mut_slice_from(self.pos), left); + slice::bytes::copy_memory(self.buf.mut_slice_from(self.pos), left); } if right.len() > 0 { self.buf.push_all(right); @@ -171,7 +171,7 @@ impl Reader for MemReader { let input = self.buf.slice(self.pos, self.pos + write_len); let output = buf.mut_slice(0, write_len); assert_eq!(input.len(), output.len()); - vec::bytes::copy_memory(output, input); + slice::bytes::copy_memory(output, input); } self.pos += write_len; assert!(self.pos <= self.buf.len()); @@ -246,7 +246,7 @@ impl<'a> Writer for BufWriter<'a> { }) } - vec::bytes::copy_memory(self.buf.mut_slice_from(self.pos), buf); + slice::bytes::copy_memory(self.buf.mut_slice_from(self.pos), buf); self.pos += buf.len(); Ok(()) } @@ -303,7 +303,7 @@ impl<'a> Reader for BufReader<'a> { let input = self.buf.slice(self.pos, self.pos + write_len); let output = buf.mut_slice(0, write_len); assert_eq!(input.len(), output.len()); - vec::bytes::copy_memory(output, input); + slice::bytes::copy_memory(output, input); } self.pos += write_len; assert!(self.pos <= self.buf.len()); diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index c18d4e273c4..cbced77d014 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -223,8 +223,8 @@ use str::{StrSlice, OwnedStr}; use str; use uint; use unstable::finally::try_finally; -use vec::{OwnedVector, MutableVector, ImmutableVector, OwnedCloneableVector}; -use vec; +use slice::{OwnedVector, MutableVector, ImmutableVector, OwnedCloneableVector}; +use slice; // Reexports pub use self::stdio::stdin; @@ -406,7 +406,7 @@ pub trait Reader { /// (not returned as part of the error). If this is unacceptable, then it is /// recommended to use the `push_bytes` or `read` methods. fn read_bytes(&mut self, len: uint) -> IoResult<~[u8]> { - let mut buf = vec::with_capacity(len); + let mut buf = slice::with_capacity(len); match self.push_bytes(&mut buf, len) { Ok(()) => Ok(buf), Err(e) => Err(e), @@ -422,7 +422,7 @@ pub trait Reader { /// /// When EOF is encountered, all bytes read up to that point are returned. fn read_to_end(&mut self) -> IoResult<~[u8]> { - let mut buf = vec::with_capacity(DEFAULT_BUF_SIZE); + let mut buf = slice::with_capacity(DEFAULT_BUF_SIZE); loop { match self.push_bytes(&mut buf, DEFAULT_BUF_SIZE) { Ok(()) => {} diff --git a/src/libstd/io/net/addrinfo.rs b/src/libstd/io/net/addrinfo.rs index 80ca353523f..6e0b766a587 100644 --- a/src/libstd/io/net/addrinfo.rs +++ b/src/libstd/io/net/addrinfo.rs @@ -23,7 +23,7 @@ use io::IoResult; use io::net::ip::{SocketAddr, IpAddr}; use option::{Option, Some, None}; use rt::rtio::{IoFactory, LocalIo}; -use vec::ImmutableVector; +use slice::ImmutableVector; /// Hints to the types of sockets that are desired when looking up hosts pub enum SocketType { diff --git a/src/libstd/io/net/ip.rs b/src/libstd/io/net/ip.rs index 7c9321d87d9..dc24ead6258 100644 --- a/src/libstd/io/net/ip.rs +++ b/src/libstd/io/net/ip.rs @@ -16,7 +16,7 @@ use from_str::FromStr; use iter::Iterator; use option::{Option, None, Some}; use str::StrSlice; -use vec::{MutableCloneableVector, ImmutableVector, MutableVector}; +use slice::{MutableCloneableVector, ImmutableVector, MutableVector}; pub type Port = u16; diff --git a/src/libstd/io/signal.rs b/src/libstd/io/signal.rs index c66fcd13917..d6700fda23d 100644 --- a/src/libstd/io/signal.rs +++ b/src/libstd/io/signal.rs @@ -27,7 +27,7 @@ use mem::drop; use option::{Some, None}; use result::{Ok, Err}; use rt::rtio::{IoFactory, LocalIo, RtioSignal}; -use vec::{ImmutableVector, OwnedVector}; +use slice::{ImmutableVector, OwnedVector}; /// Signals that can be sent and received #[repr(int)] diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index 7c65e76ab47..2389a8655f3 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -40,7 +40,7 @@ use rt::local::Local; use rt::rtio::{DontClose, IoFactory, LocalIo, RtioFileStream, RtioTTY}; use rt::task::Task; use str::StrSlice; -use vec::ImmutableVector; +use slice::ImmutableVector; // And so begins the tale of acquiring a uv handle to a stdio stream on all // platforms in all situations. Our story begins by splitting the world into two diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index d6d1de00d86..2df0dec2d13 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -13,7 +13,7 @@ use prelude::*; use cmp; use io; -use vec::bytes::MutableByteVector; +use slice::bytes::MutableByteVector; /// Wraps a `Reader`, limiting the number of bytes that can be read from it. pub struct LimitReader { diff --git a/src/libstd/iter.rs b/src/libstd/iter.rs index 9e988eb4094..320383d4f81 100644 --- a/src/libstd/iter.rs +++ b/src/libstd/iter.rs @@ -2293,7 +2293,7 @@ pub mod order { #[test] fn test_lt() { - use vec::ImmutableVector; + use slice::ImmutableVector; let empty: [int, ..0] = []; let xs = [1,2,3]; diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 17c0e2235c0..c6a1d710a52 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -119,7 +119,7 @@ pub mod bool; pub mod char; pub mod tuple; -pub mod vec; +pub mod slice; pub mod vec_ng; pub mod str; diff --git a/src/libstd/local_data.rs b/src/libstd/local_data.rs index 9fc635647f3..f1f1977462f 100644 --- a/src/libstd/local_data.rs +++ b/src/libstd/local_data.rs @@ -42,7 +42,7 @@ local_data::get(key_vector, |opt| assert_eq!(*opt.unwrap(), ~[4])); use cast; use option::{None, Option, Some}; -use vec::{ImmutableVector, MutableVector, OwnedVector}; +use slice::{ImmutableVector, MutableVector, OwnedVector}; use iter::{Iterator}; use rt::task::{Task, LocalStorage}; use mem::replace; diff --git a/src/libstd/num/mod.rs b/src/libstd/num/mod.rs index f53c95de414..98379b5e5fb 100644 --- a/src/libstd/num/mod.rs +++ b/src/libstd/num/mod.rs @@ -1727,12 +1727,12 @@ mod bench { extern crate test; use self::test::BenchHarness; use num; - use vec; + use slice; use prelude::*; #[bench] fn bench_pow_function(b: &mut BenchHarness) { - let v = vec::from_fn(1024, |n| n); + let v = slice::from_fn(1024, |n| n); b.iter(|| {v.iter().fold(0, |old, new| num::pow(old, *new));}); } } diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs index 00497b6f0ea..9d3d012bae7 100644 --- a/src/libstd/num/strconv.rs +++ b/src/libstd/num/strconv.rs @@ -18,8 +18,8 @@ use option::{None, Option, Some}; use char; use str::{StrSlice}; use str; -use vec::{CloneableVector, ImmutableVector, MutableVector}; -use vec::OwnedVector; +use slice::{CloneableVector, ImmutableVector, MutableVector}; +use slice::OwnedVector; use num; use num::{NumCast, Zero, One, cast, Int}; use num::{Round, Float, FPNaN, FPInfinite, ToPrimitive}; diff --git a/src/libstd/option.rs b/src/libstd/option.rs index ea9ccde0be9..5f733302d6f 100644 --- a/src/libstd/option.rs +++ b/src/libstd/option.rs @@ -145,7 +145,7 @@ use default::Default; use iter::{Iterator, DoubleEndedIterator, FromIterator, ExactSize}; use kinds::Send; use mem; -use vec; +use slice; /// The `Option` #[deriving(Clone, Eq, Ord, TotalEq, TotalOrd, Show)] @@ -215,7 +215,7 @@ impl Option { #[inline] pub fn as_slice<'r>(&'r self) -> &'r [T] { match *self { - Some(ref x) => vec::ref_slice(x), + Some(ref x) => slice::ref_slice(x), None => &[] } } @@ -224,7 +224,7 @@ impl Option { #[inline] pub fn as_mut_slice<'r>(&'r mut self) -> &'r mut [T] { match *self { - Some(ref mut x) => vec::mut_ref_slice(x), + Some(ref mut x) => slice::mut_ref_slice(x), None => &mut [] } } @@ -614,7 +614,7 @@ mod tests { use iter::range; use str::StrSlice; use kinds::marker; - use vec::ImmutableVector; + use slice::ImmutableVector; #[test] fn test_get_ptr() { diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 040d5c0e175..d03757c1e69 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -47,7 +47,7 @@ use fmt; use sync::atomics::{AtomicInt, INIT_ATOMIC_INT, SeqCst}; use path::{Path, GenericPath}; use iter::Iterator; -use vec::{Vector, CloneableVector, ImmutableVector, MutableVector, OwnedVector}; +use slice::{Vector, CloneableVector, ImmutableVector, MutableVector, OwnedVector}; use ptr::RawPtr; #[cfg(unix)] @@ -101,8 +101,8 @@ pub mod win32 { use os::TMPBUF_SZ; use str::StrSlice; use str; - use vec::{MutableVector, ImmutableVector, OwnedVector}; - use vec; + use slice::{MutableVector, ImmutableVector, OwnedVector}; + use slice; pub fn fill_utf16_buf_and_decode(f: |*mut u16, DWORD| -> DWORD) -> Option<~str> { @@ -112,7 +112,7 @@ pub mod win32 { let mut res = None; let mut done = false; while !done { - let mut buf = vec::from_elem(n as uint, 0u16); + let mut buf = slice::from_elem(n as uint, 0u16); let k = f(buf.as_mut_ptr(), n); if k == (0 as DWORD) { done = true; @@ -412,7 +412,7 @@ pub fn self_exe_name() -> Option { unsafe { use libc::funcs::bsd44::*; use libc::consts::os::extra::*; - use vec; + use slice; let mib = ~[CTL_KERN as c_int, KERN_PROC as c_int, KERN_PROC_PATHNAME as c_int, -1 as c_int]; @@ -422,7 +422,7 @@ pub fn self_exe_name() -> Option { 0u as libc::size_t); if err != 0 { return None; } if sz == 0 { return None; } - let mut v: ~[u8] = vec::with_capacity(sz as uint); + let mut v: ~[u8] = slice::with_capacity(sz as uint); let err = sysctl(mib.as_ptr(), mib.len() as ::libc::c_uint, v.as_mut_ptr() as *mut c_void, &mut sz, ptr::null(), 0u as libc::size_t); @@ -448,11 +448,11 @@ pub fn self_exe_name() -> Option { fn load_self() -> Option<~[u8]> { unsafe { use libc::funcs::extra::_NSGetExecutablePath; - use vec; + use slice; let mut sz: u32 = 0; _NSGetExecutablePath(ptr::mut_null(), &mut sz); if sz == 0 { return None; } - let mut v: ~[u8] = vec::with_capacity(sz as uint); + let mut v: ~[u8] = slice::with_capacity(sz as uint); let err = _NSGetExecutablePath(v.as_mut_ptr() as *mut i8, &mut sz); if err != 0 { return None; } v.set_len(sz as uint - 1); // chop off trailing NUL @@ -817,7 +817,7 @@ fn real_args() -> ~[~str] { #[cfg(windows)] fn real_args() -> ~[~str] { - use vec; + use slice; let mut nArgs: c_int = 0; let lpArgCount: *mut c_int = &mut nArgs; @@ -833,7 +833,7 @@ fn real_args() -> ~[~str] { while *ptr.offset(len as int) != 0 { len += 1; } // Push it onto the list. - let opt_s = vec::raw::buf_as_slice(ptr, len, |buf| { + let opt_s = slice::raw::buf_as_slice(ptr, len, |buf| { str::from_utf16(str::truncate_utf16_at_nul(buf)) }); args.push(opt_s.expect("CommandLineToArgvW returned invalid UTF-16")); diff --git a/src/libstd/path/mod.rs b/src/libstd/path/mod.rs index 09124f63361..c8465eb039f 100644 --- a/src/libstd/path/mod.rs +++ b/src/libstd/path/mod.rs @@ -71,9 +71,9 @@ use iter::Iterator; use option::{Option, None, Some}; use str; use str::{MaybeOwned, OwnedStr, Str, StrSlice, from_utf8_lossy}; -use vec; -use vec::{CloneableVector, OwnedCloneableVector, OwnedVector, Vector}; -use vec::{ImmutableEqVector, ImmutableVector}; +use slice; +use slice::{CloneableVector, OwnedCloneableVector, OwnedVector, Vector}; +use slice::{ImmutableEqVector, ImmutableVector}; /// Typedef for POSIX file paths. /// See `posix::Path` for more info. @@ -300,7 +300,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { } else { let mut v; let extension = extension.container_as_bytes(); - v = vec::with_capacity(name.len() + extension.len() + 1); + v = slice::with_capacity(name.len() + extension.len() + 1); v.push_all(name); v.push(dot); v.push_all(extension); @@ -313,7 +313,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { } else { let mut v; let extension = extension.container_as_bytes(); - v = vec::with_capacity(idx + extension.len() + 1); + v = slice::with_capacity(idx + extension.len() + 1); v.push_all(name.slice_to(idx+1)); v.push_all(extension); Some(v) diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs index 8345a2d04d1..f654f59266a 100644 --- a/src/libstd/path/posix.rs +++ b/src/libstd/path/posix.rs @@ -20,9 +20,9 @@ use iter::{AdditiveIterator, Extendable, Iterator, Map}; use option::{Option, None, Some}; use str; use str::Str; -use vec; -use vec::{CloneableVector, RevSplits, Splits, Vector, VectorVector, - ImmutableEqVector, OwnedVector, ImmutableVector, OwnedCloneableVector}; +use slice; +use slice::{CloneableVector, RevSplits, Splits, Vector, VectorVector, + ImmutableEqVector, OwnedVector, ImmutableVector, OwnedCloneableVector}; use super::{BytesContainer, GenericPath, GenericPathUnsafe}; /// Iterator that yields successive components of a Path as &[u8] @@ -125,7 +125,7 @@ impl GenericPathUnsafe for Path { let filename = filename.container_as_bytes(); match self.sepidx { None if bytes!("..") == self.repr => { - let mut v = vec::with_capacity(3 + filename.len()); + let mut v = slice::with_capacity(3 + filename.len()); v.push_all(dot_dot_static); v.push(SEP_BYTE); v.push_all(filename); @@ -135,14 +135,14 @@ impl GenericPathUnsafe for Path { self.repr = Path::normalize(filename); } Some(idx) if self.repr.slice_from(idx+1) == bytes!("..") => { - let mut v = vec::with_capacity(self.repr.len() + 1 + filename.len()); + let mut v = slice::with_capacity(self.repr.len() + 1 + filename.len()); v.push_all(self.repr); v.push(SEP_BYTE); v.push_all(filename); self.repr = Path::normalize(v); } Some(idx) => { - let mut v = vec::with_capacity(idx + 1 + filename.len()); + let mut v = slice::with_capacity(idx + 1 + filename.len()); v.push_all(self.repr.slice_to(idx+1)); v.push_all(filename); self.repr = Path::normalize(v); @@ -157,7 +157,7 @@ impl GenericPathUnsafe for Path { if path[0] == SEP_BYTE { self.repr = Path::normalize(path); } else { - let mut v = vec::with_capacity(self.repr.len() + path.len() + 1); + let mut v = slice::with_capacity(self.repr.len() + path.len() + 1); v.push_all(self.repr); v.push(SEP_BYTE); v.push_all(path); @@ -346,7 +346,7 @@ impl Path { } else { let n = if is_abs { comps.len() } else { comps.len() - 1} + comps.iter().map(|v| v.len()).sum(); - let mut v = vec::with_capacity(n); + let mut v = slice::with_capacity(n); let mut it = comps.move_iter(); if !is_abs { match it.next() { diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index 180078ae959..dba8af4128b 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -22,7 +22,7 @@ use iter::{AdditiveIterator, DoubleEndedIterator, Extendable, Rev, Iterator, Map use option::{Option, Some, None}; use str; use str::{CharSplits, OwnedStr, Str, StrVector, StrSlice}; -use vec::{Vector, OwnedVector, ImmutableVector}; +use slice::{Vector, OwnedVector, ImmutableVector}; use super::{contains_nul, BytesContainer, GenericPath, GenericPathUnsafe}; /// Iterator that yields successive components of a Path as &str diff --git a/src/libstd/prelude.rs b/src/libstd/prelude.rs index a04b59ae601..0b1de74330d 100644 --- a/src/libstd/prelude.rs +++ b/src/libstd/prelude.rs @@ -55,10 +55,10 @@ pub use to_str::{ToStr, IntoStr}; pub use tuple::{Tuple1, Tuple2, Tuple3, Tuple4}; pub use tuple::{Tuple5, Tuple6, Tuple7, Tuple8}; pub use tuple::{Tuple9, Tuple10, Tuple11, Tuple12}; -pub use vec::{ImmutableEqVector, ImmutableTotalOrdVector, ImmutableCloneableVector}; -pub use vec::{OwnedVector, OwnedCloneableVector, OwnedEqVector}; -pub use vec::{MutableVector, MutableTotalOrdVector}; -pub use vec::{Vector, VectorVector, CloneableVector, ImmutableVector}; +pub use slice::{ImmutableEqVector, ImmutableTotalOrdVector, ImmutableCloneableVector}; +pub use slice::{OwnedVector, OwnedCloneableVector, OwnedEqVector}; +pub use slice::{MutableVector, MutableTotalOrdVector}; +pub use slice::{Vector, VectorVector, CloneableVector, ImmutableVector}; // Reexported runtime types pub use comm::{channel, Sender, Receiver}; diff --git a/src/libstd/ptr.rs b/src/libstd/ptr.rs index bf5ba6db5c3..179100255c4 100644 --- a/src/libstd/ptr.rs +++ b/src/libstd/ptr.rs @@ -388,7 +388,7 @@ pub mod ptr_tests { use cast; use libc; use str; - use vec::{ImmutableVector, MutableVector}; + use slice::{ImmutableVector, MutableVector}; #[test] fn test() { diff --git a/src/libstd/repr.rs b/src/libstd/repr.rs index c1b276899d5..f623dd472fd 100644 --- a/src/libstd/repr.rs +++ b/src/libstd/repr.rs @@ -28,7 +28,7 @@ use reflect::{MovePtr, align}; use result::{Ok, Err}; use str::StrSlice; use to_str::ToStr; -use vec::OwnedVector; +use slice::OwnedVector; use intrinsics::{Disr, Opaque, TyDesc, TyVisitor, get_tydesc, visit_tydesc}; use raw; diff --git a/src/libstd/rt/args.rs b/src/libstd/rt/args.rs index 6f73265978b..53b8db8499d 100644 --- a/src/libstd/rt/args.rs +++ b/src/libstd/rt/args.rs @@ -124,10 +124,10 @@ mod imp { #[cfg(not(test))] unsafe fn load_argc_and_argv(argc: int, argv: **u8) -> ~[~[u8]] { use c_str::CString; - use {vec, libc}; - use vec::CloneableVector; + use {slice, libc}; + use slice::CloneableVector; - vec::from_fn(argc as uint, |i| { + slice::from_fn(argc as uint, |i| { let cs = CString::new(*(argv as **libc::c_char).offset(i as int), false); cs.as_bytes_no_nul().to_owned() }) diff --git a/src/libstd/rt/at_exit_imp.rs b/src/libstd/rt/at_exit_imp.rs index 185f4b4edd7..96dcc5244c0 100644 --- a/src/libstd/rt/at_exit_imp.rs +++ b/src/libstd/rt/at_exit_imp.rs @@ -18,7 +18,7 @@ use mem; use option::{Some, None}; use ptr::RawPtr; use unstable::sync::Exclusive; -use vec::OwnedVector; +use slice::OwnedVector; type Queue = Exclusive<~[proc()]>; diff --git a/src/libstd/rt/backtrace.rs b/src/libstd/rt/backtrace.rs index bc75a98e085..7ae2521c423 100644 --- a/src/libstd/rt/backtrace.rs +++ b/src/libstd/rt/backtrace.rs @@ -349,7 +349,7 @@ mod imp { use path::GenericPath; use ptr::RawPtr; use ptr; - use vec::{ImmutableVector, MutableVector}; + use slice::{ImmutableVector, MutableVector}; //////////////////////////////////////////////////////////////////////// // libbacktrace.h API @@ -510,7 +510,7 @@ mod imp { use unstable::dynamic_lib::DynamicLibrary; use intrinsics; use unstable::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT}; - use vec::ImmutableVector; + use slice::ImmutableVector; extern "system" { fn GetCurrentProcess() -> libc::HANDLE; diff --git a/src/libstd/rt/crate_map.rs b/src/libstd/rt/crate_map.rs index c6d5a80208b..52cced26254 100644 --- a/src/libstd/rt/crate_map.rs +++ b/src/libstd/rt/crate_map.rs @@ -16,7 +16,7 @@ use rt::rtio::EventLoop; #[cfg(stage0)] use cmp::TotalOrd; #[cfg(stage0)] use container::MutableSet; #[cfg(stage0)] use iter::Iterator; -#[cfg(stage0)] use vec::{ImmutableVector, OwnedVector}; +#[cfg(stage0)] use slice::{ImmutableVector, OwnedVector}; // Need to tell the linker on OS X to not barf on undefined symbols // and instead look them up at runtime, which we need to resolve diff --git a/src/libstd/rt/local_heap.rs b/src/libstd/rt/local_heap.rs index 29b3dcaa4f2..91452f5aa0d 100644 --- a/src/libstd/rt/local_heap.rs +++ b/src/libstd/rt/local_heap.rs @@ -21,7 +21,7 @@ use rt::global_heap; use rt::local::Local; use rt::task::Task; use raw; -use vec::ImmutableVector; +use slice::ImmutableVector; use vec_ng::Vec; // This has no meaning with out rtdebug also turned on. diff --git a/src/libstd/rt/util.rs b/src/libstd/rt/util.rs index 6fe4db54944..4c208a64ddf 100644 --- a/src/libstd/rt/util.rs +++ b/src/libstd/rt/util.rs @@ -20,7 +20,7 @@ use os; use result::Ok; use str::StrSlice; use unstable::running_on_valgrind; -use vec::ImmutableVector; +use slice::ImmutableVector; // Indicates whether we should perform expensive sanity checks, including rtassert! // FIXME: Once the runtime matures remove the `true` below to turn off rtassert, etc. diff --git a/src/libstd/vec.rs b/src/libstd/slice.rs similarity index 98% rename from src/libstd/vec.rs rename to src/libstd/slice.rs index 8080f57550b..12718c55923 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/slice.rs @@ -158,7 +158,7 @@ pub fn from_elem(n_elts: uint, t: T) -> ~[T] { // FIXME (#7136): manually inline from_fn for 2x plus speedup (sadly very // important, from_elem is a bottleneck in borrowck!). Unfortunately it // still is substantially slower than using the unsafe - // vec::with_capacity/ptr::set_memory for primitive types. + // slice::with_capacity/ptr::set_memory for primitive types. unsafe { let mut v = with_capacity(n_elts); let p = v.as_mut_ptr(); @@ -1464,7 +1464,7 @@ impl OwnedVector for ~[T] { fn reserve_additional(&mut self, n: uint) { if self.capacity() - self.len() < n { match self.len().checked_add(&n) { - None => fail!("vec::reserve_additional: `uint` overflow"), + None => fail!("slice::reserve_additional: `uint` overflow"), Some(new_cap) => self.reserve(new_cap) } } @@ -2430,7 +2430,7 @@ pub trait MutableCloneableVector { /// # Example /// /// ```rust - /// use std::vec::MutableCloneableVector; + /// use std::slice::MutableCloneableVector; /// /// let mut dst = [0, 0, 0]; /// let src = [1, 2]; @@ -2497,7 +2497,7 @@ pub mod raw { use cast::transmute; use ptr; use ptr::RawPtr; - use vec::{with_capacity, MutableVector, OwnedVector}; + use slice::{with_capacity, MutableVector, OwnedVector}; use raw::Slice; /** @@ -2576,7 +2576,7 @@ pub mod raw { /// Operations on `[u8]`. pub mod bytes { use container::Container; - use vec::{MutableVector, OwnedVector, ImmutableVector}; + use slice::{MutableVector, OwnedVector, ImmutableVector}; use ptr; use ptr::RawPtr; @@ -2952,7 +2952,7 @@ impl Extendable for ~[A] { mod tests { use prelude::*; use mem; - use vec::*; + use slice::*; use cmp::*; use rand::{Rng, task_rng}; @@ -4105,7 +4105,7 @@ mod tests { #[test] fn test_bytes_set_memory() { - use vec::bytes::MutableByteVector; + use slice::bytes::MutableByteVector; let mut values = [1u8,2,3,4,5]; values.mut_slice(0,5).set_memory(0xAB); assert!(values == [0xAB, 0xAB, 0xAB, 0xAB, 0xAB]); @@ -4185,11 +4185,11 @@ mod tests { let xs = ~[Foo, Foo, Foo]; assert_eq!(format!("{:?}", xs.slice(0, 2).to_owned()), - ~"~[vec::tests::Foo, vec::tests::Foo]"); + ~"~[slice::tests::Foo, slice::tests::Foo]"); let xs: [Foo, ..3] = [Foo, Foo, Foo]; assert_eq!(format!("{:?}", xs.slice(0, 2).to_owned()), - ~"~[vec::tests::Foo, vec::tests::Foo]"); + ~"~[slice::tests::Foo, slice::tests::Foo]"); cnt = 0; for f in xs.iter() { assert!(*f == Foo); @@ -4365,13 +4365,13 @@ mod bench { use prelude::*; use ptr; use rand::{weak_rng, Rng}; - use vec; + use slice; #[bench] fn iterator(bh: &mut BenchHarness) { // peculiar numbers to stop LLVM from optimising the summation // out. - let v = vec::from_fn(100, |i| i ^ (i << 1) ^ (i >> 1)); + let v = slice::from_fn(100, |i| i ^ (i << 1) ^ (i >> 1)); bh.iter(|| { let mut sum = 0; @@ -4385,7 +4385,7 @@ mod bench { #[bench] fn mut_iterator(bh: &mut BenchHarness) { - let mut v = vec::from_elem(100, 0); + let mut v = slice::from_elem(100, 0); bh.iter(|| { let mut i = 0; @@ -4407,7 +4407,7 @@ mod bench { #[bench] fn concat(bh: &mut BenchHarness) { - let xss: &[~[uint]] = vec::from_fn(100, |i| range(0, i).collect()); + let xss: &[~[uint]] = slice::from_fn(100, |i| range(0, i).collect()); bh.iter(|| { let _ = xss.concat_vec(); }); @@ -4415,7 +4415,7 @@ mod bench { #[bench] fn connect(bh: &mut BenchHarness) { - let xss: &[~[uint]] = vec::from_fn(100, |i| range(0, i).collect()); + let xss: &[~[uint]] = slice::from_fn(100, |i| range(0, i).collect()); bh.iter(|| { let _ = xss.connect_vec(&0); }); @@ -4432,7 +4432,7 @@ mod bench { #[bench] fn starts_with_same_vector(bh: &mut BenchHarness) { - let vec: ~[uint] = vec::from_fn(100, |i| i); + let vec: ~[uint] = slice::from_fn(100, |i| i); bh.iter(|| { vec.starts_with(vec) }) @@ -4448,8 +4448,8 @@ mod bench { #[bench] fn starts_with_diff_one_element_at_end(bh: &mut BenchHarness) { - let vec: ~[uint] = vec::from_fn(100, |i| i); - let mut match_vec: ~[uint] = vec::from_fn(99, |i| i); + let vec: ~[uint] = slice::from_fn(100, |i| i); + let mut match_vec: ~[uint] = slice::from_fn(99, |i| i); match_vec.push(0); bh.iter(|| { vec.starts_with(match_vec) @@ -4458,7 +4458,7 @@ mod bench { #[bench] fn ends_with_same_vector(bh: &mut BenchHarness) { - let vec: ~[uint] = vec::from_fn(100, |i| i); + let vec: ~[uint] = slice::from_fn(100, |i| i); bh.iter(|| { vec.ends_with(vec) }) @@ -4474,8 +4474,8 @@ mod bench { #[bench] fn ends_with_diff_one_element_at_beginning(bh: &mut BenchHarness) { - let vec: ~[uint] = vec::from_fn(100, |i| i); - let mut match_vec: ~[uint] = vec::from_fn(100, |i| i); + let vec: ~[uint] = slice::from_fn(100, |i| i); + let mut match_vec: ~[uint] = slice::from_fn(100, |i| i); match_vec[0] = 200; bh.iter(|| { vec.starts_with(match_vec) @@ -4484,7 +4484,7 @@ mod bench { #[bench] fn contains_last_element(bh: &mut BenchHarness) { - let vec: ~[uint] = vec::from_fn(100, |i| i); + let vec: ~[uint] = slice::from_fn(100, |i| i); bh.iter(|| { vec.contains(&99u) }) @@ -4493,14 +4493,14 @@ mod bench { #[bench] fn zero_1kb_from_elem(bh: &mut BenchHarness) { bh.iter(|| { - let _v: ~[u8] = vec::from_elem(1024, 0u8); + let _v: ~[u8] = slice::from_elem(1024, 0u8); }); } #[bench] fn zero_1kb_set_memory(bh: &mut BenchHarness) { bh.iter(|| { - let mut v: ~[u8] = vec::with_capacity(1024); + let mut v: ~[u8] = slice::with_capacity(1024); unsafe { let vp = v.as_mut_ptr(); ptr::set_memory(vp, 0, 1024); @@ -4522,7 +4522,7 @@ mod bench { // Slower because the { len, cap, [0 x T] }* repr allows a pointer to the length // field to be aliased (in theory) and prevents LLVM from optimizing loads away. bh.iter(|| { - let mut v: ~[u8] = vec::with_capacity(1024); + let mut v: ~[u8] = slice::with_capacity(1024); unsafe { v.set_len(1024); } @@ -4535,7 +4535,7 @@ mod bench { #[bench] fn zero_1kb_mut_iter(bh: &mut BenchHarness) { bh.iter(|| { - let mut v: ~[u8] = vec::with_capacity(1024); + let mut v: ~[u8] = slice::with_capacity(1024); unsafe { v.set_len(1024); } @@ -4550,7 +4550,7 @@ mod bench { fn random_inserts(bh: &mut BenchHarness) { let mut rng = weak_rng(); bh.iter(|| { - let mut v = vec::from_elem(30, (0u, 0u)); + let mut v = slice::from_elem(30, (0u, 0u)); for _ in range(0, 100) { let l = v.len(); v.insert(rng.gen::() % (l + 1), @@ -4562,7 +4562,7 @@ mod bench { fn random_removes(bh: &mut BenchHarness) { let mut rng = weak_rng(); bh.iter(|| { - let mut v = vec::from_elem(130, (0u, 0u)); + let mut v = slice::from_elem(130, (0u, 0u)); for _ in range(0, 100) { let l = v.len(); v.remove(rng.gen::() % l); @@ -4602,7 +4602,7 @@ mod bench { #[bench] fn sort_sorted(bh: &mut BenchHarness) { - let mut v = vec::from_fn(10000, |i| i); + let mut v = slice::from_fn(10000, |i| i); bh.iter(|| { v.sort(); }); @@ -4643,7 +4643,7 @@ mod bench { #[bench] fn sort_big_sorted(bh: &mut BenchHarness) { - let mut v = vec::from_fn(10000u, |i| (i, i, i, i)); + let mut v = slice::from_fn(10000u, |i| (i, i, i, i)); bh.iter(|| { v.sort(); }); diff --git a/src/libstd/str.rs b/src/libstd/str.rs index ccd08e8a716..92e86a5cccb 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -99,8 +99,8 @@ use option::{None, Option, Some}; use ptr; use ptr::RawPtr; use from_str::FromStr; -use vec; -use vec::{OwnedVector, OwnedCloneableVector, ImmutableVector, MutableVector}; +use slice; +use slice::{OwnedVector, OwnedCloneableVector, ImmutableVector, MutableVector}; use vec_ng::Vec; use default::Default; use raw::Repr; @@ -360,7 +360,7 @@ pub type RevCharOffsets<'a> = Rev>; /// External iterator for a string's bytes. /// Use with the `std::iter` module. pub type Bytes<'a> = - Map<'a, &'a u8, u8, vec::Items<'a, u8>>; + Map<'a, &'a u8, u8, slice::Items<'a, u8>>; /// External iterator for a string's bytes in reverse order. /// Use with the `std::iter` module. @@ -738,7 +738,7 @@ Section: Misc /// `iter` reset such that it is pointing at the first byte in the /// invalid sequence. #[inline(always)] -fn run_utf8_validation_iterator(iter: &mut vec::Items) -> bool { +fn run_utf8_validation_iterator(iter: &mut slice::Items) -> bool { loop { // save the current thing we're pointing at. let old = *iter; @@ -855,7 +855,7 @@ pub fn is_utf16(v: &[u16]) -> bool { /// of `u16`s. #[deriving(Clone)] pub struct UTF16Items<'a> { - priv iter: vec::Items<'a, u16> + priv iter: slice::Items<'a, u16> } /// The possibilities for values decoded from a `u16` stream. #[deriving(Eq, TotalEq, Clone, Show)] @@ -1025,7 +1025,7 @@ pub fn from_utf16_lossy(v: &[u16]) -> ~str { #[inline] pub fn with_capacity(capacity: uint) -> ~str { unsafe { - cast::transmute(vec::with_capacity::<~[u8]>(capacity)) + cast::transmute(slice::with_capacity::<~[u8]>(capacity)) } } @@ -1360,13 +1360,13 @@ pub mod raw { use ptr::RawPtr; use option::{Option, Some, None}; use str::{is_utf8, OwnedStr, StrSlice}; - use vec; - use vec::{MutableVector, ImmutableVector, OwnedVector}; + use slice; + use slice::{MutableVector, ImmutableVector, OwnedVector}; use raw::Slice; /// Create a Rust string from a *u8 buffer of the given length pub unsafe fn from_buf_len(buf: *u8, len: uint) -> ~str { - let mut v: ~[u8] = vec::with_capacity(len); + let mut v: ~[u8] = slice::with_capacity(len); ptr::copy_memory(v.as_mut_ptr(), buf, len); v.set_len(len); @@ -1463,7 +1463,7 @@ pub mod raw { /// The caller must preserve the valid UTF-8 property. #[inline] pub unsafe fn push_bytes(s: &mut ~str, bytes: &[u8]) { - vec::bytes::push_bytes(as_owned_vec(s), bytes); + slice::bytes::push_bytes(as_owned_vec(s), bytes); } /// Removes the last byte from a string and returns it. @@ -2603,7 +2603,7 @@ impl<'a> StrSlice<'a> for &'a str { fn to_owned(&self) -> ~str { let len = self.len(); unsafe { - let mut v = vec::with_capacity(len); + let mut v = slice::with_capacity(len); ptr::copy_memory(v.as_mut_ptr(), self.as_ptr(), len); v.set_len(len); @@ -2766,7 +2766,7 @@ impl<'a> StrSlice<'a> for &'a str { if slen == 0 { return tlen; } if tlen == 0 { return slen; } - let mut dcol = vec::from_fn(tlen + 1, |x| x); + let mut dcol = slice::from_fn(tlen + 1, |x| x); for (i, sc) in self.chars().enumerate() { @@ -2921,7 +2921,7 @@ impl OwnedStr for ~str { // Attempt to not use an intermediate buffer by just pushing bytes // directly onto this string. let write_ptr = v.as_mut_ptr().offset(cur_len as int); - let used = vec::raw::mut_buf_as_slice(write_ptr, 4, |slc| c.encode_utf8(slc)); + let used = slice::raw::mut_buf_as_slice(write_ptr, 4, |slc| c.encode_utf8(slc)); v.set_len(cur_len + used); } @@ -4667,7 +4667,7 @@ mod bench { #[bench] fn from_utf8_lossy_100_invalid(bh: &mut BenchHarness) { - let s = ::vec::from_elem(100, 0xF5u8); + let s = ::slice::from_elem(100, 0xF5u8); bh.iter(|| { let _ = from_utf8_lossy(s); }); diff --git a/src/libstd/sync/arc.rs b/src/libstd/sync/arc.rs index 56c71a5e4ff..883e81355e1 100644 --- a/src/libstd/sync/arc.rs +++ b/src/libstd/sync/arc.rs @@ -27,7 +27,7 @@ use kinds::Send; use ops::Drop; use ptr::RawPtr; use sync::atomics::{fence, AtomicUint, Relaxed, Acquire, Release}; -use vec; +use slice; /// An atomically reference counted pointer. /// @@ -69,7 +69,7 @@ impl UnsafeArc { ~[] // need to free data here } else { let ptr = new_inner(data, num_handles); - vec::from_fn(num_handles, |_| UnsafeArc { data: ptr }) + slice::from_fn(num_handles, |_| UnsafeArc { data: ptr }) } } } diff --git a/src/libstd/sync/deque.rs b/src/libstd/sync/deque.rs index 1cd6920612e..658ee48af1a 100644 --- a/src/libstd/sync/deque.rs +++ b/src/libstd/sync/deque.rs @@ -61,7 +61,7 @@ use ptr::RawPtr; use sync::arc::UnsafeArc; use sync::atomics::{AtomicInt, AtomicPtr, SeqCst}; use unstable::sync::Exclusive; -use vec::{OwnedVector, ImmutableVector}; +use slice::{OwnedVector, ImmutableVector}; // Once the queue is less than 1/K full, then it will be downsized. Note that // the deque requires that this number be less than 2. @@ -404,7 +404,7 @@ mod tests { use rand::Rng; use sync::atomics::{AtomicBool, INIT_ATOMIC_BOOL, SeqCst, AtomicUint, INIT_ATOMIC_UINT}; - use vec; + use slice; #[test] fn smoke() { @@ -600,7 +600,7 @@ mod tests { let mut pool = BufferPool::<(int, uint)>::new(); let (mut w, s) = pool.deque(); - let (threads, hits) = vec::unzip(range(0, NTHREADS).map(|_| { + let (threads, hits) = slice::unzip(range(0, NTHREADS).map(|_| { let s = s.clone(); let unique_box = ~AtomicUint::new(0); let thread_box = unsafe { diff --git a/src/libstd/sync/mpmc_bounded_queue.rs b/src/libstd/sync/mpmc_bounded_queue.rs index ad0434c634a..95f592baff0 100644 --- a/src/libstd/sync/mpmc_bounded_queue.rs +++ b/src/libstd/sync/mpmc_bounded_queue.rs @@ -35,7 +35,7 @@ use num::next_power_of_two; use option::{Option, Some, None}; use sync::arc::UnsafeArc; use sync::atomics::{AtomicUint,Relaxed,Release,Acquire}; -use vec; +use slice; struct Node { sequence: AtomicUint, @@ -69,8 +69,8 @@ impl State { } else { capacity }; - let buffer = vec::from_fn(capacity, |i:uint| { - Node{sequence:AtomicUint::new(i),value:None} + let buffer = slice::from_fn(capacity, |i| { + Node { sequence:AtomicUint::new(i), value: None } }); State{ pad0: [0, ..64], diff --git a/src/libstd/unicode.rs b/src/libstd/unicode.rs index b43003f0de2..645db8e040b 100644 --- a/src/libstd/unicode.rs +++ b/src/libstd/unicode.rs @@ -13,10 +13,9 @@ #[allow(missing_doc)]; #[allow(non_uppercase_statics)]; - fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool { use cmp::{Equal, Less, Greater}; - use vec::ImmutableVector; + use slice::ImmutableVector; use option::None; r.bsearch(|&(lo,hi)| { if lo <= c && c <= hi { Equal } @@ -25,7 +24,6 @@ fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool { }) != None } - pub mod general_category { static Cc_table : &'static [(char,char)] = &[ ('\x00', '\x1f'), ('\x7f', '\x9f') @@ -108,7 +106,7 @@ pub mod general_category { pub mod decompose { use option::Option; use option::{Some, None}; - use vec::ImmutableVector; + use slice::ImmutableVector; fn bsearch_table(c: char, r: &'static [(char, &'static [char])]) -> Option<&'static [char]> { use cmp::{Equal, Less, Greater}; @@ -4136,8 +4134,8 @@ pub mod derived_property { pub fn XID_Start(c: char) -> bool { super::bsearch_range_table(c, XID_Start_table) } - } + pub mod property { static White_Space_table : &'static [(char,char)] = &[ ('\x09', '\x0d'), ('\x20', '\x20'), @@ -4151,12 +4149,11 @@ pub mod property { pub fn White_Space(c: char) -> bool { super::bsearch_range_table(c, White_Space_table) } - } -pub mod conversions { +pub mod conversions { use cmp::{Equal, Less, Greater}; - use vec::ImmutableVector; + use slice::ImmutableVector; use tuple::Tuple2; use option::{Option, Some, None}; @@ -4181,7 +4178,8 @@ pub mod conversions { else { Greater } }) } - static LuLl_table : &'static [(char, char)] = &[ + + static LuLl_table : &'static [(char, char)] = &[ ('\x41', '\x61'), ('\x42', '\x62'), ('\x43', '\x63'), ('\x44', '\x64'), ('\x45', '\x65'), ('\x46', '\x66'), diff --git a/src/libstd/vec_ng.rs b/src/libstd/vec_ng.rs index 04e3ad920ec..553f528745b 100644 --- a/src/libstd/vec_ng.rs +++ b/src/libstd/vec_ng.rs @@ -27,8 +27,8 @@ use ptr::RawPtr; use ptr; use rt::global_heap::{malloc_raw, realloc_raw}; use raw::Slice; -use vec::{ImmutableEqVector, ImmutableVector, Items, MutItems, MutableVector}; -use vec::{MutableTotalOrdVector}; +use slice::{ImmutableEqVector, ImmutableVector, Items, MutItems, MutableVector}; +use slice::{MutableTotalOrdVector}; /// An owned, growable vector /// diff --git a/src/libsync/arc.rs b/src/libsync/arc.rs index faa7a9de542..1d49771ed38 100644 --- a/src/libsync/arc.rs +++ b/src/libsync/arc.rs @@ -21,11 +21,11 @@ * extern crate sync; * extern crate rand; * - * use std::vec; + * use std::slice; * use sync::Arc; * * fn main() { - * let numbers = vec::from_fn(100, |i| (i as f32) * rand::random()); + * let numbers = slice::from_fn(100, |i| (i as f32) * rand::random()); * let shared_numbers = Arc::new(numbers); * * for _ in range(0, 10) { diff --git a/src/libsync/task_pool.rs b/src/libsync/task_pool.rs index 93487827200..7670e9cf50a 100644 --- a/src/libsync/task_pool.rs +++ b/src/libsync/task_pool.rs @@ -13,9 +13,8 @@ /// A task pool abstraction. Useful for achieving predictable CPU /// parallelism. - use std::task; -use std::vec; +use std::slice; enum Msg { Execute(proc(&T)), @@ -47,7 +46,7 @@ impl TaskPool { -> TaskPool { assert!(n_tasks >= 1); - let channels = vec::from_fn(n_tasks, |i| { + let channels = slice::from_fn(n_tasks, |i| { let (tx, rx) = channel::>(); let init_fn = init_fn_factory(); diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 4ef46573e23..77b0d4b5c9d 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -520,7 +520,7 @@ pub enum Expr_ { ExprIndex(@Expr, @Expr), /// Expression that looks like a "name". For example, - /// `std::vec::from_elem::` is an ExprPath that's the "name" part + /// `std::slice::from_elem::` is an ExprPath that's the "name" part /// of a function call. ExprPath(Path), diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index f7983933990..bfe3f833695 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -20,7 +20,7 @@ use util::small_vector::SmallVector; use std::cell::RefCell; use std::iter; -use std::vec; +use std::slice; use std::fmt; use std::vec_ng::Vec; @@ -65,9 +65,9 @@ impl<'a> Iterator for LinkedPath<'a> { } } -// HACK(eddyb) move this into libstd (value wrapper for vec::Items). +// HACK(eddyb) move this into libstd (value wrapper for slice::Items). #[deriving(Clone)] -pub struct Values<'a, T>(vec::Items<'a, T>); +pub struct Values<'a, T>(slice::Items<'a, T>); impl<'a, T: Pod> Iterator for Values<'a, T> { fn next(&mut self) -> Option { diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs index e79e584ed5c..3bfc4f6e51d 100644 --- a/src/libsyntax/ext/format.rs +++ b/src/libsyntax/ext/format.rs @@ -20,7 +20,7 @@ use rsparse = parse; use std::fmt::parse; use collections::{HashMap, HashSet}; -use std::vec; +use std::slice; use std::vec_ng::Vec; #[deriving(Eq)] @@ -610,7 +610,7 @@ impl<'a, 'b> Context<'a, 'b> { fn to_expr(&self, extra: @ast::Expr) -> @ast::Expr { let mut lets = Vec::new(); let mut locals = Vec::new(); - let mut names = vec::from_fn(self.name_positions.len(), |_| None); + let mut names = slice::from_fn(self.name_positions.len(), |_| None); let mut pats = Vec::new(); let mut heads = Vec::new(); diff --git a/src/libsyntax/opt_vec.rs b/src/libsyntax/opt_vec.rs index ec81fff51c7..aee387d6d96 100644 --- a/src/libsyntax/opt_vec.rs +++ b/src/libsyntax/opt_vec.rs @@ -16,7 +16,7 @@ */ use std::default::Default; -use std::vec; +use std::slice; use std::vec_ng::Vec; #[deriving(Clone, Encodable, Decodable, Hash)] @@ -176,7 +176,7 @@ impl Default for OptVec { } pub struct Items<'a, T> { - priv iter: Option> + priv iter: Option> } impl<'a, T> Iterator<&'a T> for Items<'a, T> { diff --git a/src/libterm/terminfo/parm.rs b/src/libterm/terminfo/parm.rs index dfb6d6b1a88..ee14b90fbfd 100644 --- a/src/libterm/terminfo/parm.rs +++ b/src/libterm/terminfo/parm.rs @@ -10,7 +10,7 @@ //! Parameterized string expansion -use std::{char, vec}; +use std::{char, slice}; use std::mem::replace; #[deriving(Eq)] @@ -93,7 +93,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables) let mut state = Nothing; // expanded cap will only rarely be larger than the cap itself - let mut output = vec::with_capacity(cap.len()); + let mut output = slice::with_capacity(cap.len()); let mut stack: ~[Param] = ~[]; @@ -488,7 +488,7 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<~[u8],~str> { (FormatString, _) => return Err(~"non-number on stack with %s"), }; if flags.precision > s.len() { - let mut s_ = vec::with_capacity(flags.precision); + let mut s_ = slice::with_capacity(flags.precision); let n = flags.precision - s.len(); s_.grow(n, &('0' as u8)); s_.push_all_move(s); @@ -543,7 +543,7 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<~[u8],~str> { if flags.left { s.grow(n, &(' ' as u8)); } else { - let mut s_ = vec::with_capacity(flags.width); + let mut s_ = slice::with_capacity(flags.width); s_.grow(n, &(' ' as u8)); s_.push_all_move(s); s = s_; diff --git a/src/libterm/terminfo/parser/compiled.rs b/src/libterm/terminfo/parser/compiled.rs index 8ba3ad53121..cc97e54709c 100644 --- a/src/libterm/terminfo/parser/compiled.rs +++ b/src/libterm/terminfo/parser/compiled.rs @@ -13,7 +13,7 @@ /// ncurses-compatible compiled terminfo format parsing (term(5)) -use std::{vec, str}; +use std::{slice, str}; use std::io; use collections::HashMap; use super::super::TermInfo; @@ -246,7 +246,7 @@ pub fn parse(file: &mut io::Reader, let mut string_map = HashMap::new(); if string_offsets_count != 0 { - let mut string_offsets = vec::with_capacity(10); + let mut string_offsets = slice::with_capacity(10); for _ in range(0, string_offsets_count) { string_offsets.push(try!(file.read_le_u16())); } diff --git a/src/libtest/stats.rs b/src/libtest/stats.rs index b3fd06bd6ad..120b790d467 100644 --- a/src/libtest/stats.rs +++ b/src/libtest/stats.rs @@ -1035,7 +1035,7 @@ mod tests { #[cfg(test)] mod bench { use BenchHarness; - use std::vec; + use std::slice; use stats::Stats; #[bench] @@ -1047,7 +1047,7 @@ mod bench { #[bench] pub fn sum_many_f64(bh: &mut BenchHarness) { let nums = [-1e30, 1e60, 1e30, 1.0, -1e60]; - let v = vec::from_fn(500, |i| nums[i%5]); + let v = slice::from_fn(500, |i| nums[i%5]); bh.iter(|| { v.sum(); diff --git a/src/libuuid/lib.rs b/src/libuuid/lib.rs index 98c5f413973..7aed4cd3d9b 100644 --- a/src/libuuid/lib.rs +++ b/src/libuuid/lib.rs @@ -85,7 +85,7 @@ use std::from_str::FromStr; use std::hash::Hash; use std::num::FromStrRadix; use std::str; -use std::vec; +use std::slice; use rand::Rng; @@ -202,7 +202,7 @@ impl Uuid { pub fn new_v4() -> Uuid { let ub = rand::task_rng().gen_vec(16); let mut uuid = Uuid{ bytes: [0, .. 16] }; - vec::bytes::copy_memory(uuid.bytes, ub); + slice::bytes::copy_memory(uuid.bytes, ub); uuid.set_variant(VariantRFC4122); uuid.set_version(Version4Random); uuid @@ -229,7 +229,7 @@ impl Uuid { fields.data1 = to_be32(d1 as i32) as u32; fields.data2 = to_be16(d2 as i16) as u16; fields.data3 = to_be16(d3 as i16) as u16; - vec::bytes::copy_memory(fields.data4, d4); + slice::bytes::copy_memory(fields.data4, d4); unsafe { transmute(fields) @@ -246,7 +246,7 @@ impl Uuid { } let mut uuid = Uuid{ bytes: [0, .. 16] }; - vec::bytes::copy_memory(uuid.bytes, b); + slice::bytes::copy_memory(uuid.bytes, b); Some(uuid) } @@ -329,7 +329,7 @@ impl Uuid { /// /// Example: `936DA01F9ABD4d9d80C702AF85C822A8` pub fn to_simple_str(&self) -> ~str { - let mut s: ~[u8] = vec::from_elem(32, 0u8); + let mut s: ~[u8] = slice::from_elem(32, 0u8); for i in range(0u, 16u) { let digit = format!("{:02x}", self.bytes[i] as uint); s[i*2+0] = digit[0]; @@ -523,7 +523,7 @@ impl rand::Rand for Uuid { fn rand(rng: &mut R) -> Uuid { let ub = rng.gen_vec(16); let mut uuid = Uuid{ bytes: [0, .. 16] }; - vec::bytes::copy_memory(uuid.bytes, ub); + slice::bytes::copy_memory(uuid.bytes, ub); uuid.set_variant(VariantRFC4122); uuid.set_version(Version4Random); uuid diff --git a/src/test/bench/core-map.rs b/src/test/bench/core-map.rs index fcea5222e10..9f91284a413 100644 --- a/src/test/bench/core-map.rs +++ b/src/test/bench/core-map.rs @@ -16,7 +16,7 @@ use collections::{TrieMap, TreeMap, HashMap, HashSet}; use std::os; use rand::{Rng, IsaacRng, SeedableRng}; use std::uint; -use std::vec; +use std::slice; fn timed(label: &str, f: ||) { let start = time::precise_time_s(); @@ -99,7 +99,7 @@ fn main() { } }; - let mut rand = vec::with_capacity(n_keys); + let mut rand = slice::with_capacity(n_keys); { let mut rng: IsaacRng = SeedableRng::from_seed(&[1, 1, 1, 1, 1, 1, 1]); diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs index 120caa53293..6bf145e7976 100644 --- a/src/test/bench/core-std.rs +++ b/src/test/bench/core-std.rs @@ -20,7 +20,7 @@ use rand::Rng; use std::mem::swap; use std::os; use std::str; -use std::vec; +use std::slice; use std::io::File; macro_rules! bench ( @@ -61,7 +61,7 @@ fn maybe_run_test(argv: &[~str], name: ~str, test: ||) { } fn shift_push() { - let mut v1 = vec::from_elem(30000, 1); + let mut v1 = slice::from_elem(30000, 1); let mut v2 = ~[]; while v1.len() > 0 { @@ -88,7 +88,7 @@ fn vec_plus() { let mut v = ~[]; let mut i = 0; while i < 1500 { - let rv = vec::from_elem(r.gen_range(0u, i + 1), i); + let rv = slice::from_elem(r.gen_range(0u, i + 1), i); if r.gen() { v.push_all_move(rv); } else { @@ -104,12 +104,12 @@ fn vec_append() { let mut v = ~[]; let mut i = 0; while i < 1500 { - let rv = vec::from_elem(r.gen_range(0u, i + 1), i); + let rv = slice::from_elem(r.gen_range(0u, i + 1), i); if r.gen() { - v = vec::append(v, rv); + v = slice::append(v, rv); } else { - v = vec::append(rv, v); + v = slice::append(rv, v); } i += 1; } @@ -120,7 +120,7 @@ fn vec_push_all() { let mut v = ~[]; for i in range(0u, 1500) { - let mut rv = vec::from_elem(r.gen_range(0u, i + 1), i); + let mut rv = slice::from_elem(r.gen_range(0u, i + 1), i); if r.gen() { v.push_all(rv); } diff --git a/src/test/bench/shootout-fannkuch-redux.rs b/src/test/bench/shootout-fannkuch-redux.rs index 2f637030802..8d860206d0c 100644 --- a/src/test/bench/shootout-fannkuch-redux.rs +++ b/src/test/bench/shootout-fannkuch-redux.rs @@ -9,7 +9,7 @@ // except according to those terms. use std::os; -use std::vec; +use std::slice; fn max(a: i32, b: i32) -> i32 { if a > b { @@ -20,9 +20,9 @@ fn max(a: i32, b: i32) -> i32 { } fn fannkuch_redux(n: i32) -> i32 { - let mut perm = vec::from_elem(n as uint, 0i32); - let mut perm1 = vec::from_fn(n as uint, |i| i as i32); - let mut count = vec::from_elem(n as uint, 0i32); + let mut perm = slice::from_elem(n as uint, 0i32); + let mut perm1 = slice::from_fn(n as uint, |i| i as i32); + let mut count = slice::from_elem(n as uint, 0i32); let mut max_flips_count = 0i32; let mut perm_count = 0i32; let mut checksum = 0i32; diff --git a/src/test/bench/shootout-fasta-redux.rs b/src/test/bench/shootout-fasta-redux.rs index 532bc714d31..fead298bc86 100644 --- a/src/test/bench/shootout-fasta-redux.rs +++ b/src/test/bench/shootout-fasta-redux.rs @@ -11,8 +11,8 @@ use std::cmp::min; use std::io::{stdout, IoResult}; use std::os; -use std::vec::bytes::copy_memory; -use std::vec; +use std::slice::bytes::copy_memory; +use std::slice; static LINE_LEN: uint = 60; static LOOKUP_SIZE: uint = 4 * 1024; @@ -89,7 +89,7 @@ impl<'a, W: Writer> RepeatFasta<'a, W> { fn make(&mut self, n: uint) -> IoResult<()> { let alu_len = self.alu.len(); - let mut buf = vec::from_elem(alu_len + LINE_LEN, 0u8); + let mut buf = slice::from_elem(alu_len + LINE_LEN, 0u8); let alu: &[u8] = self.alu.as_bytes(); copy_memory(buf, alu); diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index 2ddcd2b5bfd..0b5a19aaec8 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -24,7 +24,7 @@ use std::os; use std::io; use std::str; use std::task; -use std::vec; +use std::slice; fn f64_cmp(x: f64, y: f64) -> Ordering { // arbitrarily decide that NaNs are larger than everything. @@ -157,7 +157,7 @@ fn main() { // initialize each sequence sorter let sizes = ~[1u,2,3,4,6,12,18]; - let mut streams = vec::from_fn(sizes.len(), |_| Some(channel::<~str>())); + let mut streams = slice::from_fn(sizes.len(), |_| Some(channel::<~str>())); let mut from_child = ~[]; let to_child = sizes.iter().zip(streams.mut_iter()).map(|(sz, stream_ref)| { let sz = *sz; diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs index 2ddea19b4c9..1a981480ebe 100644 --- a/src/test/bench/shootout-k-nucleotide.rs +++ b/src/test/bench/shootout-k-nucleotide.rs @@ -11,7 +11,7 @@ // ignore-pretty use std::str; -use std::vec; +use std::slice; static TABLE: [u8, ..4] = [ 'A' as u8, 'C' as u8, 'G' as u8, 'T' as u8 ]; static TABLE_SIZE: uint = 2 << 16; @@ -97,14 +97,14 @@ struct Table { struct Items<'a> { cur: Option<&'a Entry>, - items: vec::Items<'a, Option<~Entry>>, + items: slice::Items<'a, Option<~Entry>>, } impl Table { fn new() -> Table { Table { count: 0, - items: vec::from_fn(TABLE_SIZE, |_| None), + items: slice::from_fn(TABLE_SIZE, |_| None), } } diff --git a/src/test/bench/shootout-meteor.rs b/src/test/bench/shootout-meteor.rs index 496e09b4651..97f2c887515 100644 --- a/src/test/bench/shootout-meteor.rs +++ b/src/test/bench/shootout-meteor.rs @@ -180,7 +180,7 @@ fn get_id(m: u64) -> u8 { // Converts a list of mask to a ~str. fn to_utf8(raw_sol: &List) -> ~str { - let mut sol: ~[u8] = std::vec::from_elem(50, '.' as u8); + let mut sol: ~[u8] = std::slice::from_elem(50, '.' as u8); for &m in raw_sol.iter() { let id = get_id(m); for i in range(0, 50) { diff --git a/src/test/bench/shootout-spectralnorm.rs b/src/test/bench/shootout-spectralnorm.rs index 87b58023c69..ea8253f6e42 100644 --- a/src/test/bench/shootout-spectralnorm.rs +++ b/src/test/bench/shootout-spectralnorm.rs @@ -14,7 +14,7 @@ use std::from_str::FromStr; use std::iter::count; use std::cmp::min; use std::os; -use std::vec::from_elem; +use std::slice::from_elem; use sync::RWArc; fn A(i: uint, j: uint) -> f64 { diff --git a/src/test/bench/sudoku.rs b/src/test/bench/sudoku.rs index e69ede619de..ba94290bd03 100644 --- a/src/test/bench/sudoku.rs +++ b/src/test/bench/sudoku.rs @@ -17,7 +17,7 @@ use std::io::stdio::StdReader; use std::io::BufferedReader; use std::os; use std::intrinsics::cttz16; -use std::vec; +use std::slice; // Computes a single solution to a given 9x9 sudoku // @@ -48,8 +48,8 @@ impl Sudoku { } pub fn from_vec(vec: &[[u8, ..9], ..9]) -> Sudoku { - let g = vec::from_fn(9u, |i| { - vec::from_fn(9u, |j| { vec[i][j] }) + let g = slice::from_fn(9u, |i| { + slice::from_fn(9u, |j| { vec[i][j] }) }); return Sudoku::new(g) } @@ -68,7 +68,7 @@ impl Sudoku { pub fn read(mut reader: BufferedReader) -> Sudoku { assert!(reader.read_line().unwrap() == ~"9,9"); /* assert first line is exactly "9,9" */ - let mut g = vec::from_fn(10u, { |_i| ~[0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8] }); + let mut g = slice::from_fn(10u, { |_i| ~[0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8] }); for line in reader.lines() { let comps: ~[&str] = line.unwrap().trim().split(',').collect(); diff --git a/src/test/bench/task-perf-one-million.rs b/src/test/bench/task-perf-one-million.rs index c3c255b2dc8..75975b76ecb 100644 --- a/src/test/bench/task-perf-one-million.rs +++ b/src/test/bench/task-perf-one-million.rs @@ -15,11 +15,11 @@ use std::os; use std::task; use std::uint; -use std::vec; +use std::slice; fn calc(children: uint, parent_wait_chan: &Sender>>) { - let wait_ports: ~[Receiver>>] = vec::from_fn(children, |_| { + let wait_ports: ~[Receiver>>] = slice::from_fn(children, |_| { let (wait_port, wait_chan) = stream::>>(); task::spawn(proc() { calc(children / 2, &wait_chan); diff --git a/src/test/compile-fail/lint-deprecated-owned-vector.rs b/src/test/compile-fail/lint-deprecated-owned-vector.rs index c21ca87e244..e73e1eacc7c 100644 --- a/src/test/compile-fail/lint-deprecated-owned-vector.rs +++ b/src/test/compile-fail/lint-deprecated-owned-vector.rs @@ -13,5 +13,5 @@ fn main() { ~[1]; //~ ERROR use of deprecated `~[]` //~^ ERROR use of deprecated `~[]` - std::vec::with_capacity::(10); //~ ERROR use of deprecated `~[]` + std::slice::with_capacity::(10); //~ ERROR use of deprecated `~[]` } diff --git a/src/test/compile-fail/lint-unused-imports.rs b/src/test/compile-fail/lint-unused-imports.rs index c20546d8590..e4d9048ca8d 100644 --- a/src/test/compile-fail/lint-unused-imports.rs +++ b/src/test/compile-fail/lint-unused-imports.rs @@ -29,7 +29,7 @@ use test::B; // Make sure this import is warned about when at least one of its imported names // is unused -use std::vec::{from_fn, from_elem}; //~ ERROR unused import +use std::slice::{from_fn, from_elem}; //~ ERROR unused import mod test { pub trait A { fn a(&self) {} } diff --git a/src/test/compile-fail/liveness-issue-2163.rs b/src/test/compile-fail/liveness-issue-2163.rs index fbb6d03b220..05a6c0f6bbd 100644 --- a/src/test/compile-fail/liveness-issue-2163.rs +++ b/src/test/compile-fail/liveness-issue-2163.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::vec; +use std::slice; fn main() { let a: ~[int] = ~[]; diff --git a/src/test/run-pass/import-glob-crate.rs b/src/test/run-pass/import-glob-crate.rs index 3ba8f5eace5..dc66c888402 100644 --- a/src/test/run-pass/import-glob-crate.rs +++ b/src/test/run-pass/import-glob-crate.rs @@ -13,7 +13,7 @@ #[feature(globs)]; #[allow(dead_assignment)]; -use std::vec::*; +use std::slice::*; pub fn main() { let mut v = from_elem(0u, 0); diff --git a/src/test/run-pass/issue-2989.rs b/src/test/run-pass/issue-2989.rs index b603759380e..bfb9f54b967 100644 --- a/src/test/run-pass/issue-2989.rs +++ b/src/test/run-pass/issue-2989.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::vec; +use std::slice; trait methods { fn to_bytes(&self) -> ~[u8]; @@ -16,14 +16,14 @@ trait methods { impl methods for () { fn to_bytes(&self) -> ~[u8] { - vec::from_elem(0, 0u8) + slice::from_elem(0, 0u8) } } // the position of this function is significant! - if it comes before methods // then it works, if it comes after it then it doesn't! fn to_bools(bitv: Storage) -> ~[bool] { - vec::from_fn(8, |i| { + slice::from_fn(8, |i| { let w = i / 64; let b = i % 64; let x = 1u64 & (bitv.storage[w] >> b); diff --git a/src/test/run-pass/issue-3563-3.rs b/src/test/run-pass/issue-3563-3.rs index 7d051e378ab..d06d00a130e 100644 --- a/src/test/run-pass/issue-3563-3.rs +++ b/src/test/run-pass/issue-3563-3.rs @@ -20,7 +20,7 @@ // Extern mod controls linkage. Use controls the visibility of names to modules that are // already linked in. Using WriterUtil allows us to use the write_line method. use std::str; -use std::vec; +use std::slice; use std::fmt; // Represents a position on a canvas. @@ -62,8 +62,8 @@ impl Drop for AsciiArt { fn AsciiArt(width: uint, height: uint, fill: char) -> AsciiArt { // Use an anonymous function to build a vector of vectors containing // blank characters for each position in our canvas. - let lines = vec::build(Some(height), |push| { - for _ in range(0, height) { push(vec::from_elem(width, '.')); } + let lines = slice::build(Some(height), |push| { + for _ in range(0, height) { push(slice::from_elem(width, '.')); } }); // Rust code often returns values by omitting the trailing semi-colon diff --git a/src/test/run-pass/mod-view-items.rs b/src/test/run-pass/mod-view-items.rs index d3f79b9815e..e9fb74b4e6e 100644 --- a/src/test/run-pass/mod-view-items.rs +++ b/src/test/run-pass/mod-view-items.rs @@ -17,8 +17,8 @@ // begin failing. mod m { - use std::vec; - pub fn f() -> ~[int] { vec::from_elem(1u, 0) } + use std::slice; + pub fn f() -> ~[int] { slice::from_elem(1u, 0) } } pub fn main() { let _x = m::f(); } diff --git a/src/test/run-pass/uninit-empty-types.rs b/src/test/run-pass/uninit-empty-types.rs index df24a399f4a..54791ddd419 100644 --- a/src/test/run-pass/uninit-empty-types.rs +++ b/src/test/run-pass/uninit-empty-types.rs @@ -10,7 +10,6 @@ // Test the uninit() construct returning various empty types. -use std::vec; use std::mem; #[deriving(Clone)]