1
Fork 0

auto merge of #12772 : thestinger/rust/slice, r=alexcrichton

Closes #12702
This commit is contained in:
bors 2014-03-19 23:21:49 -07:00
commit 7aded2adb6
115 changed files with 360 additions and 365 deletions

View file

@ -32,7 +32,7 @@ use std::io;
use std::os; use std::os;
use std::str; use std::str;
use std::task; use std::task;
use std::vec; use std::slice;
use test::MetricMap; use test::MetricMap;
@ -500,7 +500,7 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
proc_res: &ProcRes) { proc_res: &ProcRes) {
// true if we found the error in question // 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); expected_errors.len(), false);
if proc_res.status.success() { if proc_res.status.success() {

View file

@ -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 like vectors. A library can choose to expose only the safe, high-level interface and hide the unsafe
internal details. 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 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 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. 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 psrc = src.as_ptr();
let mut dstlen = snappy_max_compressed_length(srclen); 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(); let pdst = dst.as_mut_ptr();
snappy_compress(psrc, srclen, pdst, &mut dstlen); snappy_compress(psrc, srclen, pdst, &mut dstlen);
@ -125,7 +125,7 @@ pub fn uncompress(src: &[u8]) -> Option<~[u8]> {
let mut dstlen: size_t = 0; let mut dstlen: size_t = 0;
snappy_uncompressed_length(psrc, srclen, &mut dstlen); 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(); let pdst = dst.as_mut_ptr();
if snappy_uncompress(psrc, srclen, pdst, &mut dstlen) == 0 { if snappy_uncompress(psrc, srclen, pdst, &mut dstlen) == 0 {

View file

@ -255,10 +255,10 @@ might look like the example below.
~~~ ~~~
# use std::task::spawn; # use std::task::spawn;
# use std::vec; # use std::slice;
// Create a vector of ports, one for each child task // 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(); let (tx, rx) = channel();
spawn(proc() { spawn(proc() {
tx.send(some_expensive_computation(init_val)); tx.send(some_expensive_computation(init_val));
@ -304,7 +304,7 @@ be distributed on the available cores.
~~~ ~~~
# extern crate sync; # extern crate sync;
# use std::vec; # use std::slice;
fn partial_sum(start: uint) -> f64 { fn partial_sum(start: uint) -> f64 {
let mut local_sum = 0f64; let mut local_sum = 0f64;
for num in range(start*100000, (start+1)*100000) { for num in range(start*100000, (start+1)*100000) {
@ -314,7 +314,7 @@ fn partial_sum(start: uint) -> f64 {
} }
fn main() { 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; let mut final_res = 0f64;
for ft in futures.mut_iter() { 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 rand;
extern crate sync; extern crate sync;
use std::vec; use std::slice;
use sync::Arc; use sync::Arc;
fn pnorm(nums: &~[f64], p: uint) -> f64 { fn pnorm(nums: &~[f64], p: uint) -> f64 {
@ -350,7 +350,7 @@ fn pnorm(nums: &~[f64], p: uint) -> f64 {
} }
fn main() { fn main() {
let numbers = vec::from_fn(1000000, |_| rand::random::<f64>()); let numbers = slice::from_fn(1000000, |_| rand::random::<f64>());
let numbers_arc = Arc::new(numbers); let numbers_arc = Arc::new(numbers);
for num in range(1u, 10) { for num in range(1u, 10) {
@ -374,9 +374,9 @@ created by the line
# extern crate sync; # extern crate sync;
# extern crate rand; # extern crate rand;
# use sync::Arc; # use sync::Arc;
# use std::vec; # use std::slice;
# fn main() { # fn main() {
# let numbers = vec::from_fn(1000000, |_| rand::random::<f64>()); # let numbers = slice::from_fn(1000000, |_| rand::random::<f64>());
let numbers_arc=Arc::new(numbers); 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 sync;
# extern crate rand; # extern crate rand;
# use sync::Arc; # use sync::Arc;
# use std::vec; # use std::slice;
# fn main() { # fn main() {
# let numbers=vec::from_fn(1000000, |_| rand::random::<f64>()); # let numbers=slice::from_fn(1000000, |_| rand::random::<f64>());
# let numbers_arc = Arc::new(numbers); # let numbers_arc = Arc::new(numbers);
# let (tx, rx) = channel(); # let (tx, rx) = channel();
tx.send(numbers_arc.clone()); tx.send(numbers_arc.clone());
@ -404,9 +404,9 @@ Each task recovers the underlying data by
# extern crate sync; # extern crate sync;
# extern crate rand; # extern crate rand;
# use sync::Arc; # use sync::Arc;
# use std::vec; # use std::slice;
# fn main() { # fn main() {
# let numbers=vec::from_fn(1000000, |_| rand::random::<f64>()); # let numbers=slice::from_fn(1000000, |_| rand::random::<f64>());
# let numbers_arc=Arc::new(numbers); # let numbers_arc=Arc::new(numbers);
# let (tx, rx) = channel(); # let (tx, rx) = channel();
# tx.send(numbers_arc.clone()); # tx.send(numbers_arc.clone());

View file

@ -188,18 +188,18 @@ For example:
# #[allow(unused_imports)]; # #[allow(unused_imports)];
extern crate test; extern crate test;
use std::vec; use std::slice;
use test::BenchHarness; use test::BenchHarness;
#[bench] #[bench]
fn bench_sum_1024_ints(b: &mut BenchHarness) { 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);} ); b.iter(|| {v.iter().fold(0, |old, new| old + *new);} );
} }
#[bench] #[bench]
fn initialise_a_vector(b: &mut BenchHarness) { 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; b.bytes = 1024 * 8;
} }

View file

@ -162,7 +162,7 @@ def emit_bsearch_range_table(f):
f.write(""" f.write("""
fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool { fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool {
use cmp::{Equal, Less, Greater}; use cmp::{Equal, Less, Greater};
use vec::ImmutableVector; use slice::ImmutableVector;
use option::None; use option::None;
r.bsearch(|&(lo,hi)| { r.bsearch(|&(lo,hi)| {
if lo <= c && c <= hi { Equal } 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("pub mod conversions {\n")
f.write(""" f.write("""
use cmp::{Equal, Less, Greater}; use cmp::{Equal, Less, Greater};
use vec::ImmutableVector; use slice::ImmutableVector;
use tuple::Tuple2; use tuple::Tuple2;
use option::{Option, Some, None}; 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("pub mod decompose {\n");
f.write(" use option::Option;\n"); f.write(" use option::Option;\n");
f.write(" use option::{Some, None};\n"); f.write(" use option::{Some, None};\n");
f.write(" use vec::ImmutableVector;\n"); f.write(" use slice::ImmutableVector;\n");
f.write(""" f.write("""
fn bsearch_table(c: char, r: &'static [(char, &'static [char])]) -> Option<&'static [char]> { fn bsearch_table(c: char, r: &'static [(char, &'static [char])]) -> Option<&'static [char]> {
use cmp::{Equal, Less, Greater}; use cmp::{Equal, Less, Greater};

View file

@ -42,7 +42,7 @@ use std::rc::Rc;
use std::rt::global_heap; use std::rt::global_heap;
use std::intrinsics::{TyDesc, get_tydesc}; use std::intrinsics::{TyDesc, get_tydesc};
use std::intrinsics; use std::intrinsics;
use std::vec; use std::slice;
// The way arena uses arrays is really deeply awful. The arrays are // The way arena uses arrays is really deeply awful. The arrays are
// allocated, and have capacities reserved, but the fill for the array // 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 { fn chunk(size: uint, is_pod: bool) -> Chunk {
Chunk { Chunk {
data: Rc::new(RefCell::new(vec::with_capacity(size))), data: Rc::new(RefCell::new(slice::with_capacity(size))),
fill: Cell::new(0u), fill: Cell::new(0u),
is_pod: Cell::new(is_pod), is_pod: Cell::new(is_pod),
} }

View file

@ -16,7 +16,7 @@ use std::iter::RandomAccessIterator;
use std::iter::{Rev, Enumerate, Repeat, Map, Zip}; use std::iter::{Rev, Enumerate, Repeat, Map, Zip};
use std::ops; use std::ops;
use std::uint; use std::uint;
use std::vec; use std::slice;
#[deriving(Clone)] #[deriving(Clone)]
struct SmallBitv { struct SmallBitv {
@ -278,13 +278,13 @@ impl Bitv {
let s = let s =
if init { if init {
if exact { if exact {
vec::from_elem(nelems, !0u) slice::from_elem(nelems, !0u)
} else { } else {
let mut v = vec::from_elem(nelems-1, !0u); let mut v = slice::from_elem(nelems-1, !0u);
v.push((1<<nbits % uint::BITS)-1); v.push((1<<nbits % uint::BITS)-1);
v v
} }
} else { vec::from_elem(nelems, 0u)}; } else { slice::from_elem(nelems, 0u)};
Big(BigBitv::new(s)) Big(BigBitv::new(s))
}; };
Bitv {rep: rep, nbits: nbits} Bitv {rep: rep, nbits: nbits}
@ -452,7 +452,7 @@ impl Bitv {
* Each `uint` in the resulting vector has either value `0u` or `1u`. * Each `uint` in the resulting vector has either value `0u` or `1u`.
*/ */
pub fn to_vec(&self) -> ~[uint] { pub fn to_vec(&self) -> ~[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 + let len = self.nbits/8 +
if self.nbits % 8 == 0 { 0 } else { 1 }; 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, 0) |
bit(self, i, 1) | bit(self, i, 1) |
bit(self, i, 2) | bit(self, i, 2) |
@ -489,7 +489,7 @@ impl Bitv {
* Transform `self` into a `[bool]` by turning each bit into a `bool`. * Transform `self` into a `[bool]` by turning each bit into a `bool`.
*/ */
pub fn to_bools(&self) -> ~[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. /// and w1/w2 are the words coming from the two vectors self, other.
fn commons<'a>(&'a self, other: &'a BitvSet) fn commons<'a>(&'a self, other: &'a BitvSet)
-> Map<'static, ((uint, &'a uint), &'a ~[uint]), (uint, uint, uint), -> Map<'static, ((uint, &'a uint), &'a ~[uint]), (uint, uint, uint),
Zip<Enumerate<vec::Items<'a, uint>>, Repeat<&'a ~[uint]>>> { Zip<Enumerate<slice::Items<'a, uint>>, Repeat<&'a ~[uint]>>> {
let min = cmp::min(self.bitv.storage.len(), other.bitv.storage.len()); let min = cmp::min(self.bitv.storage.len(), other.bitv.storage.len());
self.bitv.storage.slice(0, min).iter().enumerate() self.bitv.storage.slice(0, min).iter().enumerate()
.zip(Repeat::new(&other.bitv.storage)) .zip(Repeat::new(&other.bitv.storage))
@ -895,7 +895,7 @@ impl BitvSet {
/// `other`. /// `other`.
fn outliers<'a>(&'a self, other: &'a BitvSet) fn outliers<'a>(&'a self, other: &'a BitvSet)
-> Map<'static, ((uint, &'a uint), uint), (bool, uint, uint), -> Map<'static, ((uint, &'a uint), uint), (bool, uint, uint),
Zip<Enumerate<vec::Items<'a, uint>>, Repeat<uint>>> { Zip<Enumerate<slice::Items<'a, uint>>, Repeat<uint>>> {
let slen = self.bitv.storage.len(); let slen = self.bitv.storage.len();
let olen = other.bitv.storage.len(); let olen = other.bitv.storage.len();
@ -946,7 +946,7 @@ mod tests {
use bitv; use bitv;
use std::uint; use std::uint;
use std::vec; use std::slice;
use rand; use rand;
use rand::Rng; use rand::Rng;
@ -964,7 +964,7 @@ mod tests {
#[test] #[test]
fn test_0_elements() { fn test_0_elements() {
let act = Bitv::new(0u, false); let act = Bitv::new(0u, false);
let exp = vec::from_elem::<bool>(0u, false); let exp = slice::from_elem::<bool>(0u, false);
assert!(act.eq_vec(exp)); assert!(act.eq_vec(exp));
} }

View file

@ -44,7 +44,7 @@ pub mod bench {
extern crate test; extern crate test;
use self::test::BenchHarness; use self::test::BenchHarness;
use std::container::MutableMap; use std::container::MutableMap;
use std::vec; use std::slice;
use rand; use rand;
use rand::Rng; use rand::Rng;
@ -90,7 +90,7 @@ pub mod bench {
bh: &mut BenchHarness) { bh: &mut BenchHarness) {
// setup // setup
let mut rng = rand::XorShiftRng::new(); let mut rng = rand::XorShiftRng::new();
let mut keys = vec::from_fn(n, |_| rng.gen::<uint>() % n); let mut keys = slice::from_fn(n, |_| rng.gen::<uint>() % n);
for k in keys.iter() { for k in keys.iter() {
map.insert(*k, 1); map.insert(*k, 1);

View file

@ -27,7 +27,7 @@ use std::option::{Option, Some, None};
use rand; use rand;
use rand::Rng; use rand::Rng;
use std::result::{Ok, Err}; use std::result::{Ok, Err};
use std::vec::{ImmutableVector}; use std::slice::ImmutableVector;
mod table { mod table {
use std::clone::Clone; use std::clone::Clone;
@ -1958,7 +1958,7 @@ mod test_map {
mod test_set { mod test_set {
use super::HashSet; use super::HashSet;
use std::container::Container; use std::container::Container;
use std::vec::ImmutableEqVector; use std::slice::ImmutableEqVector;
#[test] #[test]
fn test_disjoint() { fn test_disjoint() {

View file

@ -14,7 +14,7 @@
use std::clone::Clone; use std::clone::Clone;
use std::mem::{move_val_init, init, replace, swap}; use std::mem::{move_val_init, init, replace, swap};
use std::vec; use std::slice;
/// A priority queue implemented with a binary heap /// A priority queue implemented with a binary heap
#[deriving(Clone)] #[deriving(Clone)]
@ -181,7 +181,7 @@ impl<T:Ord> PriorityQueue<T> {
/// PriorityQueue iterator /// PriorityQueue iterator
pub struct Items <'a, T> { 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> { impl<'a, T> Iterator<&'a T> for Items<'a, T> {

View file

@ -14,7 +14,7 @@
//! extra::container::Deque`. //! extra::container::Deque`.
use std::cmp; use std::cmp;
use std::vec; use std::slice;
use std::iter::{Rev, RandomAccessIterator}; use std::iter::{Rev, RandomAccessIterator};
use deque::Deque; use deque::Deque;
@ -118,7 +118,7 @@ impl<T> RingBuf<T> {
/// Create an empty RingBuf with space for at least `n` elements. /// Create an empty RingBuf with space for at least `n` elements.
pub fn with_capacity(n: uint) -> RingBuf<T> { pub fn with_capacity(n: uint) -> RingBuf<T> {
RingBuf{nelts: 0, lo: 0, 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 /// Retrieve an element in the RingBuf by index

View file

@ -17,7 +17,7 @@
use std::iter::{Enumerate, FilterMap, Rev}; use std::iter::{Enumerate, FilterMap, Rev};
use std::mem::replace; use std::mem::replace;
use std::vec; use std::slice;
#[allow(missing_doc)] #[allow(missing_doc)]
pub struct SmallIntMap<T> { pub struct SmallIntMap<T> {
@ -153,7 +153,7 @@ impl<V> SmallIntMap<V> {
/// Empties the hash map, moving all values into the specified closure /// Empties the hash map, moving all values into the specified closure
pub fn move_iter(&mut self) pub fn move_iter(&mut self)
-> FilterMap<(uint, Option<V>), (uint, V), -> FilterMap<(uint, Option<V>), (uint, V),
Enumerate<vec::MoveItems<Option<V>>>> Enumerate<slice::MoveItems<Option<V>>>>
{ {
let values = replace(&mut self.v, ~[]); let values = replace(&mut self.v, ~[]);
values.move_iter().enumerate().filter_map(|(i, v)| { values.move_iter().enumerate().filter_map(|(i, v)| {
@ -236,7 +236,7 @@ macro_rules! double_ended_iterator {
pub struct Entries<'a, T> { pub struct Entries<'a, T> {
priv front: uint, priv front: uint,
priv back: uint, priv back: uint,
priv iter: vec::Items<'a, Option<T>> priv iter: slice::Items<'a, Option<T>>
} }
iterator!(impl Entries -> (uint, &'a T), get_ref) iterator!(impl Entries -> (uint, &'a T), get_ref)
@ -246,7 +246,7 @@ pub type RevEntries<'a, T> = Rev<Entries<'a, T>>;
pub struct MutEntries<'a, T> { pub struct MutEntries<'a, T> {
priv front: uint, priv front: uint,
priv back: uint, priv back: uint,
priv iter: vec::MutItems<'a, Option<T>> priv iter: slice::MutItems<'a, Option<T>>
} }
iterator!(impl MutEntries -> (uint, &'a mut T), get_mut_ref) iterator!(impl MutEntries -> (uint, &'a mut T), get_mut_ref)

View file

@ -13,8 +13,8 @@
use std::mem; use std::mem;
use std::uint; use std::uint;
use std::mem::init; use std::mem::init;
use std::vec; use std::slice;
use std::vec::{Items, MutItems}; use std::slice::{Items, MutItems};
// FIXME: #5244: need to manually update the TrieNode constructor // FIXME: #5244: need to manually update the TrieNode constructor
static SHIFT: uint = 4; static SHIFT: uint = 4;
@ -474,7 +474,7 @@ fn remove<T>(count: &mut uint, child: &mut Child<T>, key: uint,
/// Forward iterator over a map /// Forward iterator over a map
pub struct Entries<'a, T> { pub struct Entries<'a, T> {
priv stack: [vec::Items<'a, Child<T>>, .. NUM_CHUNKS], priv stack: [slice::Items<'a, Child<T>>, .. NUM_CHUNKS],
priv length: uint, priv length: uint,
priv remaining_min: uint, priv remaining_min: uint,
priv remaining_max: 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 /// Forward iterator over the key-value pairs of a map, with the
/// values being mutable. /// values being mutable.
pub struct MutEntries<'a, T> { pub struct MutEntries<'a, T> {
priv stack: [vec::MutItems<'a, Child<T>>, .. NUM_CHUNKS], priv stack: [slice::MutItems<'a, Child<T>>, .. NUM_CHUNKS],
priv length: uint, priv length: uint,
priv remaining_min: uint, priv remaining_min: uint,
priv remaining_max: uint priv remaining_max: uint

View file

@ -94,7 +94,7 @@ use std::cmp::Eq;
use std::result::{Err, Ok}; use std::result::{Err, Ok};
use std::result; use std::result;
use std::option::{Some, None}; use std::option::{Some, None};
use std::vec; use std::slice;
/// Name of an option. Either a string or a single char. /// Name of an option. Either a string or a single char.
#[deriving(Clone, Eq)] #[deriving(Clone, Eq)]
@ -525,7 +525,7 @@ pub fn getopts(args: &[~str], optgrps: &[OptGroup]) -> Result {
fn f(_x: uint) -> ~[Optval] { return ~[]; } 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 mut free: ~[~str] = ~[];
let l = args.len(); let l = args.len();
let mut i = 0; let mut i = 0;

View file

@ -188,7 +188,7 @@ use std::rt;
use std::sync::atomics::{SeqCst, AtomicUint, INIT_ATOMIC_UINT}; use std::sync::atomics::{SeqCst, AtomicUint, INIT_ATOMIC_UINT};
use std::sync::deque; use std::sync::deque;
use std::task::TaskOpts; use std::task::TaskOpts;
use std::vec; use std::slice;
use std::sync::arc::UnsafeArc; use std::sync::arc::UnsafeArc;
use sched::{Shutdown, Scheduler, SchedHandle, TaskFromFriend, NewNeighbor}; use sched::{Shutdown, Scheduler, SchedHandle, TaskFromFriend, NewNeighbor};
@ -356,8 +356,8 @@ impl SchedPool {
// Create a work queue for each scheduler, ntimes. Create an extra // 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. // 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 arr = slice::from_fn(nscheds, |_| pool.deque_pool.deque());
let (workers, stealers) = vec::unzip(arr.move_iter()); let (workers, stealers) = slice::unzip(arr.move_iter());
pool.stealers = stealers; pool.stealers = stealers;
// Now that we've got all our work queues, create one scheduler per // Now that we've got all our work queues, create one scheduler per

View file

@ -125,7 +125,7 @@ use std::io;
use std::local_data; use std::local_data;
use std::os; use std::os;
use std::rt; use std::rt;
use std::vec; use std::slice;
use std::vec_ng::Vec; use std::vec_ng::Vec;
use sync::one::{Once, ONCE_INIT}; 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, fn enabled(level: u32, module: &str,
iter: vec::Items<directive::LogDirective>) -> bool { iter: slice::Items<directive::LogDirective>) -> bool {
// Search for the longest match, the vector is assumed to be pre-sorted. // Search for the longest match, the vector is assumed to be pre-sorted.
for directive in iter.rev() { for directive in iter.rev() {
match directive.name { match directive.name {

View file

@ -18,7 +18,7 @@ use std::libc::{c_int, c_void};
use std::libc; use std::libc;
use std::mem; use std::mem;
use std::rt::rtio; use std::rt::rtio;
use std::vec; use std::slice;
use std::vec_ng::Vec; use std::vec_ng::Vec;
use io::{IoResult, retry, keep_going}; use io::{IoResult, retry, keep_going};
@ -417,7 +417,7 @@ pub fn readlink(p: &CString) -> IoResult<Path> {
if len == -1 { if len == -1 {
len = 1024; // FIXME: read PATH_MAX from C ffi? len = 1024; // FIXME: read PATH_MAX from C ffi?
} }
let mut buf = vec::with_capacity::<u8>(len as uint); let mut buf = slice::with_capacity::<u8>(len as uint);
match retry(|| unsafe { match retry(|| unsafe {
libc::readlink(p, buf.as_ptr() as *mut libc::c_char, libc::readlink(p, buf.as_ptr() as *mut libc::c_char,
len as libc::size_t) as libc::c_int len as libc::size_t) as libc::c_int

View file

@ -22,7 +22,7 @@ use std::ptr;
use std::rt::rtio; use std::rt::rtio;
use std::str; use std::str;
use std::sync::arc::UnsafeArc; use std::sync::arc::UnsafeArc;
use std::vec; use std::slice;
use io::IoResult; use io::IoResult;
@ -353,8 +353,7 @@ pub fn readdir(p: &CString) -> IoResult<~[Path]> {
if fp_buf as uint == 0 { if fp_buf as uint == 0 {
fail!("os::list_dir() failure: got null ptr from wfd"); fail!("os::list_dir() failure: got null ptr from wfd");
} else { } else {
let fp_vec = vec::from_buf(fp_buf, let fp_vec = slice::from_buf(fp_buf, libc::wcslen(fp_buf) as uint);
libc::wcslen(fp_buf) as uint);
let fp_trimmed = str::truncate_utf16_at_nul(fp_vec); let fp_trimmed = str::truncate_utf16_at_nul(fp_vec);
let fp_str = str::from_utf16(fp_trimmed) let fp_str = str::from_utf16(fp_trimmed)
.expect("rust_list_dir_wfd_fp_buf returned invalid UTF-16"); .expect("rust_list_dir_wfd_fp_buf returned invalid UTF-16");

View file

@ -572,12 +572,12 @@ fn spawn_process_os(config: p::ProcessConfig,
#[cfg(unix)] #[cfg(unix)]
fn with_argv<T>(prog: &str, args: &[~str], cb: |**libc::c_char| -> T) -> T { fn with_argv<T>(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 // 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 // a reference to the intermediary byte buffers. So first build an array to
// hold all the ~[u8] byte strings. // 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()); tmps.push(prog.to_c_str());
@ -598,14 +598,14 @@ fn with_argv<T>(prog: &str, args: &[~str], cb: |**libc::c_char| -> T) -> T {
#[cfg(unix)] #[cfg(unix)]
fn with_envp<T>(env: Option<~[(~str, ~str)]>, cb: |*c_void| -> T) -> T { fn with_envp<T>(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 // 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 // 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. // have a temporary buffer to hold the intermediary `~[u8]` byte strings.
match env { match env {
Some(env) => { Some(env) => {
let mut tmps = vec::with_capacity(env.len()); let mut tmps = slice::with_capacity(env.len());
for pair in env.iter() { for pair in env.iter() {
let kv = format!("{}={}", *pair.ref0(), *pair.ref1()); let kv = format!("{}={}", *pair.ref0(), *pair.ref1());

View file

@ -12,7 +12,7 @@
use {Rng, SeedableRng, OSRng}; use {Rng, SeedableRng, OSRng};
use std::iter::{range_step, Repeat}; use std::iter::{range_step, Repeat};
use std::vec::raw; use std::slice::raw;
use std::mem; use std::mem;
static RAND_SIZE_LEN: u32 = 8; static RAND_SIZE_LEN: u32 = 8;
@ -431,7 +431,7 @@ impl<'a> SeedableRng<&'a [u64]> for Isaac64Rng {
mod test { mod test {
use super::{IsaacRng, Isaac64Rng}; use super::{IsaacRng, Isaac64Rng};
use {Rng, SeedableRng, OSRng}; use {Rng, SeedableRng, OSRng};
use std::vec; use std::slice;
#[test] #[test]
fn test_rng_32_rand_seeded() { fn test_rng_32_rand_seeded() {
@ -491,7 +491,7 @@ mod test {
let seed = &[1, 23, 456, 7890, 12345]; let seed = &[1, 23, 456, 7890, 12345];
let mut ra: IsaacRng = SeedableRng::from_seed(seed); let mut ra: IsaacRng = SeedableRng::from_seed(seed);
// Regression test that isaac is actually using the above vector // 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, assert_eq!(v,
~[2558573138, 873787463, 263499565, 2103644246, 3595684709, ~[2558573138, 873787463, 263499565, 2103644246, 3595684709,
4203127393, 264982119, 2765226902, 2737944514, 3900253796]); 4203127393, 264982119, 2765226902, 2737944514, 3900253796]);
@ -501,7 +501,7 @@ mod test {
// skip forward to the 10000th number // skip forward to the 10000th number
for _ in range(0, 10000) { rb.next_u32(); } 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, assert_eq!(v,
~[3676831399, 3183332890, 2834741178, 3854698763, 2717568474, ~[3676831399, 3183332890, 2834741178, 3854698763, 2717568474,
1576568959, 3507990155, 179069555, 141456972, 2478885421]); 1576568959, 3507990155, 179069555, 141456972, 2478885421]);
@ -511,7 +511,7 @@ mod test {
let seed = &[1, 23, 456, 7890, 12345]; let seed = &[1, 23, 456, 7890, 12345];
let mut ra: Isaac64Rng = SeedableRng::from_seed(seed); let mut ra: Isaac64Rng = SeedableRng::from_seed(seed);
// Regression test that isaac is actually using the above vector // 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, assert_eq!(v,
~[547121783600835980, 14377643087320773276, 17351601304698403469, ~[547121783600835980, 14377643087320773276, 17351601304698403469,
1238879483818134882, 11952566807690396487, 13970131091560099343, 1238879483818134882, 11952566807690396487, 13970131091560099343,
@ -523,7 +523,7 @@ mod test {
// skip forward to the 10000th number // skip forward to the 10000th number
for _ in range(0, 10000) { rb.next_u64(); } 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, assert_eq!(v,
~[18143823860592706164, 8491801882678285927, 2699425367717515619, ~[18143823860592706164, 8491801882678285927, 2699425367717515619,
17196852593171130876, 2606123525235546165, 15790932315217671084, 17196852593171130876, 2606123525235546165, 15790932315217671084,

View file

@ -80,7 +80,7 @@ use std::cast;
use std::kinds::marker; use std::kinds::marker;
use std::local_data; use std::local_data;
use std::str; use std::str;
use std::vec; use std::slice;
pub use isaac::{IsaacRng, Isaac64Rng}; pub use isaac::{IsaacRng, Isaac64Rng};
pub use os::OSRng; pub use os::OSRng;
@ -202,7 +202,7 @@ pub trait Rng {
/// println!("{:?}", rng.gen_vec::<(f64, bool)>(5)); /// println!("{:?}", rng.gen_vec::<(f64, bool)>(5));
/// ``` /// ```
fn gen_vec<T: Rand>(&mut self, len: uint) -> ~[T] { fn gen_vec<T: Rand>(&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 /// Generate a random value in the range [`low`, `high`). Fails if
@ -342,7 +342,7 @@ pub trait Rng {
/// println!("{:?}", sample); /// println!("{:?}", sample);
/// ``` /// ```
fn sample<A, T: Iterator<A>>(&mut self, iter: T, n: uint) -> ~[A] { fn sample<A, T: Iterator<A>>(&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() { for (i, elem) in iter.enumerate() {
if i < n { if i < n {
reservoir.push(elem); reservoir.push(elem);
@ -677,7 +677,7 @@ pub struct Closed01<F>(F);
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use std::vec; use std::slice;
use super::{Rng, task_rng, random, OSRng, SeedableRng, StdRng}; use super::{Rng, task_rng, random, OSRng, SeedableRng, StdRng};
struct ConstRng { i: u64 } struct ConstRng { i: u64 }
@ -696,7 +696,7 @@ mod test {
let lengths = [0, 1, 2, 3, 4, 5, 6, 7, let lengths = [0, 1, 2, 3, 4, 5, 6, 7,
80, 81, 82, 83, 84, 85, 86, 87]; 80, 81, 82, 83, 84, 85, 86, 87];
for &n in lengths.iter() { 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); r.fill_bytes(v);
// use this to get nicer error messages. // use this to get nicer error messages.

View file

@ -14,7 +14,7 @@ use metadata::cstore;
use metadata::filesearch; use metadata::filesearch;
use collections::HashSet; use collections::HashSet;
use std::{os, vec}; use std::{os, slice};
use std::vec_ng::Vec; use std::vec_ng::Vec;
use syntax::abi; 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(); let libs = libs.move_iter().filter_map(|(_, l)| l.map(|p| p.clone())).collect();
// We don't currently rpath extern libraries, but we know // We don't currently rpath extern libraries, but we know
// where rustrt is and we know every rust program needs it // 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, let rpaths = get_rpaths(os, sysroot, output, libs,
sess.opts.target_triple); sess.opts.target_triple);

View file

@ -19,7 +19,7 @@ use front::std_inject::with_version;
use metadata::creader::Loader; use metadata::creader::Loader;
use std::cell::RefCell; use std::cell::RefCell;
use std::vec; use std::slice;
use std::vec_ng::Vec; use std::vec_ng::Vec;
use std::vec_ng; use std::vec_ng;
use syntax::ast_util::*; use syntax::ast_util::*;

View file

@ -30,7 +30,7 @@ use std::cmp;
use std::io; use std::io;
use std::os::consts::{macos, freebsd, linux, android, win32}; use std::os::consts::{macos, freebsd, linux, android, win32};
use std::str; use std::str;
use std::vec; use std::slice;
use std::vec_ng::Vec; use std::vec_ng::Vec;
use collections::{HashMap, HashSet}; use collections::{HashMap, HashSet};
@ -443,7 +443,7 @@ fn get_metadata_section_imp(os: Os, filename: &Path) -> Result<MetadataBlob, ~st
debug!("checking {} bytes of metadata-version stamp", debug!("checking {} bytes of metadata-version stamp",
vlen); vlen);
let minsz = cmp::min(vlen, csz); let minsz = cmp::min(vlen, csz);
let version_ok = vec::raw::buf_as_slice(cvbuf, minsz, let version_ok = slice::raw::buf_as_slice(cvbuf, minsz,
|buf0| buf0 == encoder::metadata_encoding_version); |buf0| buf0 == encoder::metadata_encoding_version);
if !version_ok { return Err(format!("incompatible metadata version found: '{}'", if !version_ok { return Err(format!("incompatible metadata version found: '{}'",
filename.display()));} filename.display()));}
@ -451,7 +451,7 @@ fn get_metadata_section_imp(os: Os, filename: &Path) -> Result<MetadataBlob, ~st
let cvbuf1 = cvbuf.offset(vlen as int); let cvbuf1 = cvbuf.offset(vlen as int);
debug!("inflating {} bytes of compressed metadata", debug!("inflating {} bytes of compressed metadata",
csz - vlen); csz - vlen);
vec::raw::buf_as_slice(cvbuf1, csz-vlen, |bytes| { slice::raw::buf_as_slice(cvbuf1, csz-vlen, |bytes| {
let inflated = flate::inflate_bytes(bytes); let inflated = flate::inflate_bytes(bytes);
found = Ok(MetadataVec(inflated)); found = Ok(MetadataVec(inflated));
}); });

View file

@ -19,7 +19,7 @@
use std::io; use std::io;
use std::uint; use std::uint;
use std::vec; use std::slice;
use std::vec_ng::Vec; use std::vec_ng::Vec;
use syntax::ast; use syntax::ast;
use syntax::ast_util; use syntax::ast_util;
@ -332,7 +332,7 @@ impl<'a, O:DataFlowOperator+Clone+'static> DataFlowContext<'a, O> {
changed: true 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(); let mut loop_scopes = Vec::new();
while propcx.changed { while propcx.changed {

View file

@ -32,7 +32,7 @@ use syntax::visit;
use collections::HashMap; use collections::HashMap;
use std::iter::Enumerate; use std::iter::Enumerate;
use std::vec; use std::slice;
use std::vec_ng::Vec; use std::vec_ng::Vec;
// The actual lang items defined come at the end of this file in one handy table. // 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<vec::Items<'a, Option<ast::DefId>>> { pub fn items<'a>(&'a self) -> Enumerate<slice::Items<'a, Option<ast::DefId>>> {
self.items.iter().enumerate() self.items.iter().enumerate()
} }

View file

@ -16,7 +16,7 @@
* closure. * closure.
*/ */
use std::vec; use std::slice;
use back::abi; use back::abi;
use driver::session; use driver::session;
@ -230,7 +230,7 @@ fn resolve_default_method_vtables(bcx: &Block,
vtables.len() - num_method_vtables; vtables.len() - num_method_vtables;
vtables.tailn(num_impl_type_parameters).to_owned() 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(), let param_vtables = @(vec_ng::append((*trait_vtables_fixed).clone(),

View file

@ -33,7 +33,7 @@ use util::ppaux::{Repr, ty_to_str};
use std::c_str::ToCStr; use std::c_str::ToCStr;
use std::libc::c_uint; use std::libc::c_uint;
use std::vec; use std::slice;
use std::vec_ng::Vec; use std::vec_ng::Vec;
use std::vec_ng; use std::vec_ng;
use syntax::{ast, ast_util}; 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 vec_ty = ty::expr_ty(cx.tcx(), e);
let unit_ty = ty::sequence_element_type(cx.tcx(), vec_ty); let unit_ty = ty::sequence_element_type(cx.tcx(), vec_ty);
let llunitty = type_of::type_of(cx, unit_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. // If the vector contains enums, an LLVM array won't work.
let v = if vs.iter().any(|vi| val_ty(*vi) != llunitty) { let v = if vs.iter().any(|vi| val_ty(*vi) != llunitty) {
C_struct(cx, vs, false) C_struct(cx, vs, false)
@ -563,7 +563,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
} }
} }
}).to_owned_vec(); }).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), (adt::trans_const(cx, repr, discr, cs),
inlineable.iter().fold(true, |a, &b| a && b)) 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, const_eval::const_uint(i) => i as uint,
_ => cx.sess().span_bug(count.span, "count must be integral const expression.") _ => 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) { let v = if vs.iter().any(|vi| val_ty(*vi) != llunitty) {
C_struct(cx, vs, false) C_struct(cx, vs, false)
} else { } else {

View file

@ -148,7 +148,7 @@ use collections::HashSet;
use std::libc::{c_uint, c_ulonglong, c_longlong}; use std::libc::{c_uint, c_ulonglong, c_longlong};
use std::ptr; use std::ptr;
use std::sync::atomics; use std::sync::atomics;
use std::vec; use std::slice;
use std::vec_ng::Vec; use std::vec_ng::Vec;
use syntax::codemap::{Span, Pos}; use syntax::codemap::{Span, Pos};
use syntax::{abi, ast, codemap, ast_util, ast_map, opt_vec}; 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), []); 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 // Return type -- llvm::DIBuilder wants this at index 0
match fn_decl.output.node { match fn_decl.output.node {

View file

@ -70,7 +70,7 @@ use util::nodemap::NodeMap;
use middle::trans::machine::llsize_of; use middle::trans::machine::llsize_of;
use middle::trans::type_::Type; use middle::trans::type_::Type;
use std::vec; use std::slice;
use std::vec_ng::Vec; use std::vec_ng::Vec;
use syntax::ast; use syntax::ast;
use syntax::codemap; use syntax::codemap;
@ -1010,7 +1010,7 @@ fn trans_rec_or_struct<'a>(
let ty = node_id_type(bcx, id); let ty = node_id_type(bcx, id);
let tcx = bcx.tcx(); let tcx = bcx.tcx();
with_field_tys(tcx, ty, Some(id), |discr, field_tys| { 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 numbered_fields = fields.map(|field| {
let opt_pos = let opt_pos =

View file

@ -20,7 +20,7 @@ use syntax::abi::{X86, X86_64, Arm, Mips};
use std::c_str::ToCStr; use std::c_str::ToCStr;
use std::cast; use std::cast;
use std::vec; use std::slice;
use std::vec_ng::Vec; use std::vec_ng::Vec;
use std::libc::{c_uint}; use std::libc::{c_uint};
@ -263,7 +263,7 @@ impl Type {
pub fn get_field(&self, idx: uint) -> Type { pub fn get_field(&self, idx: uint) -> Type {
unsafe { unsafe {
let num_fields = llvm::LLVMCountStructElementTypes(self.to_ref()) as uint; 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()); llvm::LLVMGetStructElementTypes(self.to_ref(), elems.as_mut_ptr());

View file

@ -118,7 +118,7 @@ use std::cell::{Cell, RefCell};
use collections::HashMap; use collections::HashMap;
use std::mem::replace; use std::mem::replace;
use std::result; use std::result;
use std::vec; use std::slice;
use std::vec_ng::Vec; use std::vec_ng::Vec;
use std::vec_ng; use std::vec_ng;
use syntax::abi::AbiSet; 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 // make a vector of booleans initially false, set to true when used
if tps.len() == 0u { return; } 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| { ty::walk_ty(ty, |t| {
match ty::get(t).sty { match ty::get(t).sty {

View file

@ -26,7 +26,7 @@ use util::ppaux::{Repr};
use std::cell::{Cell, RefCell}; use std::cell::{Cell, RefCell};
use std::uint; use std::uint;
use std::vec; use std::slice;
use std::vec_ng::Vec; use std::vec_ng::Vec;
use collections::{HashMap, HashSet}; use collections::{HashMap, HashSet};
use syntax::ast; use syntax::ast;
@ -1049,7 +1049,7 @@ impl<'a> RegionVarBindings<'a> {
// idea is to report errors that derive from independent // idea is to report errors that derive from independent
// regions of the graph, but not those that derive from // regions of the graph, but not those that derive from
// overlapping locations. // 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; let mut opt_graph = None;

View file

@ -14,7 +14,7 @@
use std::iter::range_step; use std::iter::range_step;
use std::num::Zero; use std::num::Zero;
use std::vec::bytes::{MutableByteVector, copy_memory}; use std::slice::bytes::{MutableByteVector, copy_memory};
use std::vec_ng::Vec; use std::vec_ng::Vec;
use serialize::hex::ToHex; use serialize::hex::ToHex;
@ -528,7 +528,7 @@ mod tests {
use super::{Digest, Sha256, FixedBuffer}; use super::{Digest, Sha256, FixedBuffer};
use std::num::Bounded; use std::num::Bounded;
use std::vec; use std::slice;
use std::vec_ng::Vec; use std::vec_ng::Vec;
use self::rand::isaac::IsaacRng; use self::rand::isaac::IsaacRng;
use self::rand::Rng; use self::rand::Rng;
@ -604,7 +604,7 @@ mod tests {
/// correct. /// correct.
fn test_digest_1million_random<D: Digest>(digest: &mut D, blocksize: uint, expected: &str) { fn test_digest_1million_random<D: Digest>(digest: &mut D, blocksize: uint, expected: &str) {
let total_size = 1000000; 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 rng = IsaacRng::new_unseeded();
let mut count = 0; let mut count = 0;

View file

@ -33,7 +33,7 @@ use std::libc;
use std::local_data; use std::local_data;
use std::mem; use std::mem;
use std::str; use std::str;
use std::vec; use std::slice;
use collections::HashMap; use collections::HashMap;
use html::toc::TocBuilder; 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) { extern fn block(ob: *buf, text: *buf, lang: *buf, opaque: *libc::c_void) {
unsafe { unsafe {
let my_opaque: &my_opaque = cast::transmute(opaque); 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 text = str::from_utf8(text).unwrap();
let mut lines = text.lines().filter(|l| stripped_filtered_line(*l).is_none()); let mut lines = text.lines().filter(|l| stripped_filtered_line(*l).is_none());
let text = lines.to_owned_vec().connect("\n"); 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() { let rendered = if lang.is_null() {
false false
} else { } else {
vec::raw::buf_as_slice((*lang).data, slice::raw::buf_as_slice((*lang).data,
(*lang).size as uint, |rlang| { (*lang).size as uint, |rlang| {
let rlang = str::from_utf8(rlang).unwrap(); let rlang = str::from_utf8(rlang).unwrap();
if rlang.contains("notrust") { 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() { 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) 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() { let (should_fail, no_run, ignore) = if lang.is_null() {
(false, false, false) (false, false, false)
} else { } else {
vec::raw::buf_as_slice((*lang).data, slice::raw::buf_as_slice((*lang).data,
(*lang).size as uint, |lang| { (*lang).size as uint, |lang| {
let s = str::from_utf8(lang).unwrap(); let s = str::from_utf8(lang).unwrap();
(s.contains("should_fail"), (s.contains("should_fail"),
@ -280,7 +280,7 @@ pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector) {
}) })
}; };
if ignore { return } 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 tests = &mut *(opaque as *mut ::test::Collector);
let text = str::from_utf8(text).unwrap(); let text = str::from_utf8(text).unwrap();
let mut lines = text.lines().map(|l| stripped_filtered_line(l).unwrap_or(l)); 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() { if text.is_null() {
tests.register_header("", level as u32); tests.register_header("", level as u32);
} else { } 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(); let text = str::from_utf8(text).unwrap();
tests.register_header(text, level as u32); tests.register_header(text, level as u32);
}) })

View file

@ -38,7 +38,7 @@ use std::local_data;
use std::io; use std::io;
use std::io::{fs, File, BufferedWriter, MemWriter, BufferedReader}; use std::io::{fs, File, BufferedWriter, MemWriter, BufferedReader};
use std::str; use std::str;
use std::vec; use std::slice;
use std::vec_ng::Vec; use std::vec_ng::Vec;
use collections::{HashMap, HashSet}; use collections::{HashMap, HashSet};
@ -1026,7 +1026,7 @@ fn item_module(w: &mut Writer, cx: &Context,
item: &clean::Item, items: &[clean::Item]) -> fmt::Result { item: &clean::Item, items: &[clean::Item]) -> fmt::Result {
try!(document(w, item)); try!(document(w, item));
debug!("{:?}", items); 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 { fn cmp(i1: &clean::Item, i2: &clean::Item, idx1: uint, idx2: uint) -> Ordering {
if shortty(i1) == shortty(i2) { if shortty(i1) == shortty(i2) {

View file

@ -448,7 +448,7 @@ mod test {
use std::libc::{O_CREAT, O_RDWR, O_RDONLY, S_IWUSR, S_IRUSR}; use std::libc::{O_CREAT, O_RDWR, O_RDONLY, S_IWUSR, S_IRUSR};
use std::io; use std::io;
use std::str; use std::str;
use std::vec; use std::slice;
use super::FsRequest; use super::FsRequest;
use super::super::Loop; use super::super::Loop;
use super::super::local_loop; use super::super::local_loop;
@ -484,7 +484,7 @@ mod test {
let fd = result.fd; let fd = result.fd;
// read // 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); let result = FsRequest::read(l(), fd, read_mem, 0);
assert!(result.is_ok()); assert!(result.is_ok());

View file

@ -15,7 +15,7 @@ use std::libc;
use std::ptr; use std::ptr;
use std::rt::rtio::RtioProcess; use std::rt::rtio::RtioProcess;
use std::rt::task::BlockedTask; use std::rt::task::BlockedTask;
use std::vec; use std::slice;
use homing::{HomingIO, HomeHandle}; use homing::{HomingIO, HomeHandle};
use pipe::PipeWatcher; use pipe::PipeWatcher;
@ -48,8 +48,8 @@ impl Process {
for slot in config.extra_io.iter() { for slot in config.extra_io.iter() {
io.push(*slot); io.push(*slot);
} }
let mut stdio = vec::with_capacity::<uvll::uv_stdio_container_t>(io.len()); let mut stdio = slice::with_capacity::<uvll::uv_stdio_container_t>(io.len());
let mut ret_io = vec::with_capacity(io.len()); let mut ret_io = slice::with_capacity(io.len());
unsafe { unsafe {
stdio.set_len(io.len()); stdio.set_len(io.len());
for (slot, other) in stdio.iter().zip(io.iter()) { 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<T>(prog: &str, args: &[~str], f: |**libc::c_char| -> T) -> T { fn with_argv<T>(prog: &str, args: &[~str], f: |**libc::c_char| -> T) -> T {
// First, allocation space to put all the C-strings (we need to have // First, allocation space to put all the C-strings (we need to have
// ownership of them somewhere // 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()); c_strs.push(prog.to_c_str());
for arg in args.iter() { for arg in args.iter() {
c_strs.push(arg.to_c_str()); c_strs.push(arg.to_c_str());
} }
// Next, create the char** array // 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() { for s in c_strs.iter() {
c_args.push(s.with_ref(|p| p)); c_args.push(s.with_ref(|p| p));
} }
@ -189,11 +189,11 @@ fn with_env<T>(env: Option<&[(~str, ~str)]>, f: |**libc::c_char| -> T) -> T {
None => { return f(ptr::null()); } None => { return f(ptr::null()); }
}; };
// As with argv, create some temporary storage and then the actual array // 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() { for &(ref key, ref value) in env.iter() {
envp.push(format!("{}={}", *key, *value).to_c_str()); 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() { for s in envp.iter() {
c_envp.push(s.with_ref(|p| p)); c_envp.push(s.with_ref(|p| p));
} }

View file

@ -337,11 +337,11 @@ mod tests {
#[test] #[test]
fn test_base64_random() { fn test_base64_random() {
use self::rand::{task_rng, random, Rng}; use self::rand::{task_rng, random, Rng};
use std::vec; use std::slice;
for _ in range(0, 1000) { for _ in range(0, 1000) {
let times = task_rng().gen_range(1u, 100); let times = task_rng().gen_range(1u, 100);
let v = vec::from_fn(times, |_| random::<u8>()); let v = slice::from_fn(times, |_| random::<u8>());
assert_eq!(v.to_base64(STANDARD).from_base64().unwrap(), v); assert_eq!(v.to_base64(STANDARD).from_base64().unwrap(), v);
} }
} }

View file

@ -1041,8 +1041,8 @@ mod bench {
#[bench] #[bench]
pub fn vuint_at_A_aligned(bh: &mut BenchHarness) { pub fn vuint_at_A_aligned(bh: &mut BenchHarness) {
use std::vec; use std::slice;
let data = vec::from_fn(4*100, |i| { let data = slice::from_fn(4*100, |i| {
match i % 2 { match i % 2 {
0 => 0x80u8, 0 => 0x80u8,
_ => i as u8, _ => i as u8,
@ -1060,8 +1060,8 @@ mod bench {
#[bench] #[bench]
pub fn vuint_at_A_unaligned(bh: &mut BenchHarness) { pub fn vuint_at_A_unaligned(bh: &mut BenchHarness) {
use std::vec; use std::slice;
let data = vec::from_fn(4*100+1, |i| { let data = slice::from_fn(4*100+1, |i| {
match i % 2 { match i % 2 {
1 => 0x80u8, 1 => 0x80u8,
_ => i as u8 _ => i as u8
@ -1079,8 +1079,8 @@ mod bench {
#[bench] #[bench]
pub fn vuint_at_D_aligned(bh: &mut BenchHarness) { pub fn vuint_at_D_aligned(bh: &mut BenchHarness) {
use std::vec; use std::slice;
let data = vec::from_fn(4*100, |i| { let data = slice::from_fn(4*100, |i| {
match i % 4 { match i % 4 {
0 => 0x10u8, 0 => 0x10u8,
3 => i as u8, 3 => i as u8,
@ -1099,8 +1099,8 @@ mod bench {
#[bench] #[bench]
pub fn vuint_at_D_unaligned(bh: &mut BenchHarness) { pub fn vuint_at_D_unaligned(bh: &mut BenchHarness) {
use std::vec; use std::slice;
let data = vec::from_fn(4*100+1, |i| { let data = slice::from_fn(4*100+1, |i| {
match i % 4 { match i % 4 {
1 => 0x10u8, 1 => 0x10u8,
0 => i as u8, 0 => i as u8,

View file

@ -10,7 +10,7 @@
//! Hex binary-to-text encoding //! Hex binary-to-text encoding
use std::str; use std::str;
use std::vec; use std::slice;
use std::fmt; use std::fmt;
/// A trait for converting a value to hexadecimal encoding /// A trait for converting a value to hexadecimal encoding
@ -39,7 +39,7 @@ impl<'a> ToHex for &'a [u8] {
* ``` * ```
*/ */
fn to_hex(&self) -> ~str { 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() { for &byte in self.iter() {
v.push(CHARS[byte >> 4]); v.push(CHARS[byte >> 4]);
v.push(CHARS[byte & 0xf]); v.push(CHARS[byte & 0xf]);
@ -106,7 +106,7 @@ impl<'a> FromHex for &'a str {
*/ */
fn from_hex(&self) -> Result<~[u8], FromHexError> { fn from_hex(&self) -> Result<~[u8], FromHexError> {
// This may be an overestimate if there is any whitespace // 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 modulus = 0;
let mut buf = 0u8; let mut buf = 0u8;

View file

@ -16,7 +16,7 @@ Core encoding and decoding interfaces.
use std::path; use std::path;
use std::rc::Rc; use std::rc::Rc;
use std::vec; use std::slice;
use std::vec_ng::Vec; use std::vec_ng::Vec;
pub trait Encoder { pub trait Encoder {
@ -428,7 +428,7 @@ impl<S:Encoder,T:Encodable<S>> Encodable<S> for ~[T] {
impl<D:Decoder,T:Decodable<D>> Decodable<D> for ~[T] { impl<D:Decoder,T:Decodable<D>> Decodable<D> for ~[T] {
fn decode(d: &mut D) -> ~[T] { fn decode(d: &mut D) -> ~[T] {
d.read_seq(|d, len| { d.read_seq(|d, len| {
vec::from_fn(len, |i| { slice::from_fn(len, |i| {
d.read_seq_elt(i, |d| Decodable::decode(d)) d.read_seq_elt(i, |d| Decodable::decode(d))
}) })
}) })
@ -680,7 +680,7 @@ pub trait DecoderHelpers {
impl<D:Decoder> DecoderHelpers for D { impl<D:Decoder> DecoderHelpers for D {
fn read_to_vec<T>(&mut self, f: |&mut D| -> T) -> ~[T] { fn read_to_vec<T>(&mut self, f: |&mut D| -> T) -> ~[T] {
self.read_seq(|this, len| { self.read_seq(|this, len| {
vec::from_fn(len, |i| { slice::from_fn(len, |i| {
this.read_seq_elt(i, |this| f(this)) this.read_seq_elt(i, |this| f(this))
}) })
}) })

View file

@ -19,7 +19,7 @@ use container::Container;
use cast; use cast;
use fmt; use fmt;
use iter::Iterator; use iter::Iterator;
use vec::{ImmutableVector, MutableVector, Vector}; use slice::{ImmutableVector, MutableVector, Vector};
use vec_ng::Vec; use vec_ng::Vec;
use option::{Option, Some, None}; use option::{Option, Some, None};

View file

@ -76,8 +76,8 @@ use ptr::RawPtr;
use ptr; use ptr;
use str::StrSlice; use str::StrSlice;
use str; use str;
use vec::{ImmutableVector, MutableVector}; use slice::{ImmutableVector, MutableVector};
use vec; use slice;
use rt::global_heap::malloc_raw; use rt::global_heap::malloc_raw;
use raw::Slice; use raw::Slice;
@ -343,7 +343,7 @@ impl<'a> ToCStr for &'a [u8] {
unsafe fn with_c_str<T>(v: &[u8], checked: bool, f: |*libc::c_char| -> T) -> T { unsafe fn with_c_str<T>(v: &[u8], checked: bool, f: |*libc::c_char| -> T) -> T {
if v.len() < BUF_LEN { if v.len() < BUF_LEN {
let mut buf: [u8, .. BUF_LEN] = mem::uninit(); let mut buf: [u8, .. BUF_LEN] = mem::uninit();
vec::bytes::copy_memory(buf, v); slice::bytes::copy_memory(buf, v);
buf[v.len()] = 0; buf[v.len()] = 0;
let buf = buf.as_mut_ptr(); let buf = buf.as_mut_ptr();

View file

@ -30,7 +30,7 @@ use rt::task::{Task, BlockedTask};
use rt::thread::Thread; use rt::thread::Thread;
use sync::atomics; use sync::atomics;
use unstable::mutex::NativeMutex; use unstable::mutex::NativeMutex;
use vec::OwnedVector; use slice::OwnedVector;
use mpsc = sync::mpsc_queue; use mpsc = sync::mpsc_queue;

View file

@ -30,7 +30,7 @@ use rt::task::{Task, BlockedTask};
use rt::thread::Thread; use rt::thread::Thread;
use spsc = sync::spsc_queue; use spsc = sync::spsc_queue;
use sync::atomics; use sync::atomics;
use vec::OwnedVector; use slice::OwnedVector;
static DISCONNECTED: int = int::MIN; static DISCONNECTED: int = int::MIN;
#[cfg(test)] #[cfg(test)]

View file

@ -490,8 +490,8 @@ use repr;
use result::{Ok, Err}; use result::{Ok, Err};
use str::StrSlice; use str::StrSlice;
use str; use str;
use vec::ImmutableVector; use slice::ImmutableVector;
use vec; use slice;
pub use self::num::radix; pub use self::num::radix;
pub use self::num::Radix; pub use self::num::Radix;
@ -520,7 +520,7 @@ pub struct Formatter<'a> {
/// Output buffer. /// Output buffer.
buf: &'a mut io::Writer, buf: &'a mut io::Writer,
priv curarg: vec::Items<'a, Argument<'a>>, priv curarg: slice::Items<'a, Argument<'a>>,
priv args: &'a [Argument<'a>], priv args: &'a [Argument<'a>],
} }

View file

@ -17,7 +17,7 @@ use fmt;
use iter::{Iterator, DoubleEndedIterator}; use iter::{Iterator, DoubleEndedIterator};
use num::{Int, cast, zero}; use num::{Int, cast, zero};
use option::{Some, None}; use option::{Some, None};
use vec::{ImmutableVector, MutableVector}; use slice::{ImmutableVector, MutableVector};
/// A type that represents a specific radix /// A type that represents a specific radix
trait GenericRadix { trait GenericRadix {

View file

@ -70,7 +70,7 @@ use ops::Deref;
use option::{Option, Some, None}; use option::{Option, Some, None};
use rc::Rc; use rc::Rc;
use str::{Str, StrSlice}; use str::{Str, StrSlice};
use vec::{Vector, ImmutableVector}; use slice::{Vector, ImmutableVector};
use vec_ng::Vec; use vec_ng::Vec;
/// Reexport the `sip::hash` function as our default hasher. /// Reexport the `sip::hash` function as our default hasher.
@ -293,7 +293,7 @@ mod tests {
use iter::{Iterator}; use iter::{Iterator};
use option::{Some, None}; use option::{Some, None};
use result::Ok; use result::Ok;
use vec::ImmutableVector; use slice::ImmutableVector;
use super::{Hash, Hasher}; use super::{Hash, Hasher};

View file

@ -30,7 +30,7 @@ use default::Default;
use io::{IoResult, Writer}; use io::{IoResult, Writer};
use iter::Iterator; use iter::Iterator;
use result::Ok; use result::Ok;
use vec::ImmutableVector; use slice::ImmutableVector;
use super::{Hash, Hasher}; use super::{Hash, Hasher};
@ -292,7 +292,7 @@ mod tests {
use num::ToStrRadix; use num::ToStrRadix;
use option::{Some, None}; use option::{Some, None};
use str::{Str, OwnedStr}; use str::{Str, OwnedStr};
use vec::{Vector, ImmutableVector, OwnedVector}; use slice::{Vector, ImmutableVector, OwnedVector};
use self::test::BenchHarness; use self::test::BenchHarness;
use super::super::Hash; use super::super::Hash;

View file

@ -17,8 +17,8 @@ use iter::ExactSize;
use ops::Drop; use ops::Drop;
use option::{Some, None, Option}; use option::{Some, None, Option};
use result::{Ok, Err}; use result::{Ok, Err};
use vec::{OwnedVector, ImmutableVector, MutableVector}; use slice::{OwnedVector, ImmutableVector, MutableVector};
use vec; use slice;
/// Wraps a Reader and buffers input from it /// Wraps a Reader and buffers input from it
/// ///
@ -58,7 +58,7 @@ impl<R: Reader> BufferedReader<R> {
// everything up-front. This allows creation of BufferedReader instances // everything up-front. This allows creation of BufferedReader instances
// to be very cheap (large mallocs are not nearly as expensive as large // to be very cheap (large mallocs are not nearly as expensive as large
// callocs). // callocs).
let mut buf = vec::with_capacity(cap); let mut buf = slice::with_capacity(cap);
unsafe { buf.set_len(cap); } unsafe { buf.set_len(cap); }
BufferedReader { BufferedReader {
inner: inner, inner: inner,
@ -106,7 +106,7 @@ impl<R: Reader> Reader for BufferedReader<R> {
let nread = { let nread = {
let available = try!(self.fill()); let available = try!(self.fill());
let nread = cmp::min(available.len(), buf.len()); 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 nread
}; };
self.pos += nread; self.pos += nread;
@ -140,7 +140,7 @@ impl<W: Writer> BufferedWriter<W> {
/// Creates a new `BufferedWriter` with the specified buffer capacity /// Creates a new `BufferedWriter` with the specified buffer capacity
pub fn with_capacity(cap: uint, inner: W) -> BufferedWriter<W> { pub fn with_capacity(cap: uint, inner: W) -> BufferedWriter<W> {
// See comments in BufferedReader for why this uses unsafe code. // 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); } unsafe { buf.set_len(cap); }
BufferedWriter { BufferedWriter {
inner: Some(inner), inner: Some(inner),
@ -190,7 +190,7 @@ impl<W: Writer> Writer for BufferedWriter<W> {
self.inner.get_mut_ref().write(buf) self.inner.get_mut_ref().write(buf)
} else { } else {
let dst = self.buf.mut_slice_from(self.pos); 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(); self.pos += buf.len();
Ok(()) Ok(())
} }

View file

@ -16,7 +16,7 @@ use io;
use option::{None, Option, Some}; use option::{None, Option, Some};
use result::{Ok, Err}; use result::{Ok, Err};
use super::{Reader, Writer, IoResult}; use super::{Reader, Writer, IoResult};
use vec::{bytes, CloneableVector, MutableVector, ImmutableVector}; use slice::{bytes, CloneableVector, MutableVector, ImmutableVector};
/// Allows reading from a rx. /// Allows reading from a rx.
/// ///

View file

@ -21,7 +21,7 @@ use option::{Option, Some, None};
use result::{Ok, Err}; use result::{Ok, Err};
use io; use io;
use io::{IoError, IoResult, Reader}; use io::{IoError, IoResult, Reader};
use vec::{OwnedVector, ImmutableVector}; use slice::{OwnedVector, ImmutableVector};
use ptr::RawPtr; use ptr::RawPtr;
/// An iterator that reads a single byte on each iteration, /// An iterator that reads a single byte on each iteration,
@ -114,7 +114,7 @@ pub fn u64_from_be_bytes(data: &[u8],
-> u64 { -> u64 {
use ptr::{copy_nonoverlapping_memory}; use ptr::{copy_nonoverlapping_memory};
use mem::from_be64; use mem::from_be64;
use vec::MutableVector; use slice::MutableVector;
assert!(size <= 8u); assert!(size <= 8u);
@ -470,10 +470,10 @@ mod bench {
macro_rules! u64_from_be_bytes_bench_impl( macro_rules! u64_from_be_bytes_bench_impl(
($size:expr, $stride:expr, $start_index:expr) => ($size:expr, $stride:expr, $start_index:expr) =>
({ ({
use vec; use slice;
use super::u64_from_be_bytes; 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; let mut sum = 0u64;
bh.iter(|| { bh.iter(|| {
let mut i = $start_index; let mut i = $start_index;

View file

@ -62,7 +62,7 @@ use option::{Some, None, Option};
use result::{Ok, Err}; use result::{Ok, Err};
use path; use path;
use path::{Path, GenericPath}; use path::{Path, GenericPath};
use vec::{OwnedVector, ImmutableVector}; use slice::{OwnedVector, ImmutableVector};
use vec_ng::Vec; use vec_ng::Vec;
/// Unconstrained file access type that exposes read and write operations /// Unconstrained file access type that exposes read and write operations

View file

@ -16,8 +16,8 @@ use option::None;
use result::{Err, Ok}; use result::{Err, Ok};
use io; use io;
use io::{Reader, Writer, Seek, Buffer, IoError, SeekStyle, IoResult}; use io::{Reader, Writer, Seek, Buffer, IoError, SeekStyle, IoResult};
use vec; use slice;
use vec::{Vector, ImmutableVector, MutableVector, OwnedCloneableVector}; use slice::{Vector, ImmutableVector, MutableVector, OwnedCloneableVector};
fn combine(seek: SeekStyle, cur: uint, end: uint, offset: i64) -> IoResult<u64> { fn combine(seek: SeekStyle, cur: uint, end: uint, offset: i64) -> IoResult<u64> {
// compute offset as signed and clamp to prevent overflow // 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 /// Create a new `MemWriter`, allocating at least `n` bytes for
/// the internal buffer. /// the internal buffer.
pub fn with_capacity(n: uint) -> MemWriter { 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 /// Acquires an immutable reference to the underlying buffer of this
@ -98,7 +98,7 @@ impl Writer for MemWriter {
// Do the necessary writes // Do the necessary writes
if left.len() > 0 { 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 { if right.len() > 0 {
self.buf.push_all(right); 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 input = self.buf.slice(self.pos, self.pos + write_len);
let output = buf.mut_slice(0, write_len); let output = buf.mut_slice(0, write_len);
assert_eq!(input.len(), output.len()); assert_eq!(input.len(), output.len());
vec::bytes::copy_memory(output, input); slice::bytes::copy_memory(output, input);
} }
self.pos += write_len; self.pos += write_len;
assert!(self.pos <= self.buf.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(); self.pos += buf.len();
Ok(()) Ok(())
} }
@ -303,7 +303,7 @@ impl<'a> Reader for BufReader<'a> {
let input = self.buf.slice(self.pos, self.pos + write_len); let input = self.buf.slice(self.pos, self.pos + write_len);
let output = buf.mut_slice(0, write_len); let output = buf.mut_slice(0, write_len);
assert_eq!(input.len(), output.len()); assert_eq!(input.len(), output.len());
vec::bytes::copy_memory(output, input); slice::bytes::copy_memory(output, input);
} }
self.pos += write_len; self.pos += write_len;
assert!(self.pos <= self.buf.len()); assert!(self.pos <= self.buf.len());

View file

@ -223,8 +223,8 @@ use str::{StrSlice, OwnedStr};
use str; use str;
use uint; use uint;
use unstable::finally::try_finally; use unstable::finally::try_finally;
use vec::{OwnedVector, MutableVector, ImmutableVector, OwnedCloneableVector}; use slice::{OwnedVector, MutableVector, ImmutableVector, OwnedCloneableVector};
use vec; use slice;
// Reexports // Reexports
pub use self::stdio::stdin; 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 /// (not returned as part of the error). If this is unacceptable, then it is
/// recommended to use the `push_bytes` or `read` methods. /// recommended to use the `push_bytes` or `read` methods.
fn read_bytes(&mut self, len: uint) -> IoResult<~[u8]> { 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) { match self.push_bytes(&mut buf, len) {
Ok(()) => Ok(buf), Ok(()) => Ok(buf),
Err(e) => Err(e), Err(e) => Err(e),
@ -422,7 +422,7 @@ pub trait Reader {
/// ///
/// When EOF is encountered, all bytes read up to that point are returned. /// When EOF is encountered, all bytes read up to that point are returned.
fn read_to_end(&mut self) -> IoResult<~[u8]> { 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 { loop {
match self.push_bytes(&mut buf, DEFAULT_BUF_SIZE) { match self.push_bytes(&mut buf, DEFAULT_BUF_SIZE) {
Ok(()) => {} Ok(()) => {}

View file

@ -23,7 +23,7 @@ use io::IoResult;
use io::net::ip::{SocketAddr, IpAddr}; use io::net::ip::{SocketAddr, IpAddr};
use option::{Option, Some, None}; use option::{Option, Some, None};
use rt::rtio::{IoFactory, LocalIo}; use rt::rtio::{IoFactory, LocalIo};
use vec::ImmutableVector; use slice::ImmutableVector;
/// Hints to the types of sockets that are desired when looking up hosts /// Hints to the types of sockets that are desired when looking up hosts
pub enum SocketType { pub enum SocketType {

View file

@ -16,7 +16,7 @@ use from_str::FromStr;
use iter::Iterator; use iter::Iterator;
use option::{Option, None, Some}; use option::{Option, None, Some};
use str::StrSlice; use str::StrSlice;
use vec::{MutableCloneableVector, ImmutableVector, MutableVector}; use slice::{MutableCloneableVector, ImmutableVector, MutableVector};
pub type Port = u16; pub type Port = u16;

View file

@ -27,7 +27,7 @@ use mem::drop;
use option::{Some, None}; use option::{Some, None};
use result::{Ok, Err}; use result::{Ok, Err};
use rt::rtio::{IoFactory, LocalIo, RtioSignal}; use rt::rtio::{IoFactory, LocalIo, RtioSignal};
use vec::{ImmutableVector, OwnedVector}; use slice::{ImmutableVector, OwnedVector};
/// Signals that can be sent and received /// Signals that can be sent and received
#[repr(int)] #[repr(int)]

View file

@ -40,7 +40,7 @@ use rt::local::Local;
use rt::rtio::{DontClose, IoFactory, LocalIo, RtioFileStream, RtioTTY}; use rt::rtio::{DontClose, IoFactory, LocalIo, RtioFileStream, RtioTTY};
use rt::task::Task; use rt::task::Task;
use str::StrSlice; 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 // 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 // platforms in all situations. Our story begins by splitting the world into two

View file

@ -13,7 +13,7 @@
use prelude::*; use prelude::*;
use cmp; use cmp;
use io; use io;
use vec::bytes::MutableByteVector; use slice::bytes::MutableByteVector;
/// Wraps a `Reader`, limiting the number of bytes that can be read from it. /// Wraps a `Reader`, limiting the number of bytes that can be read from it.
pub struct LimitReader<R> { pub struct LimitReader<R> {

View file

@ -2293,7 +2293,7 @@ pub mod order {
#[test] #[test]
fn test_lt() { fn test_lt() {
use vec::ImmutableVector; use slice::ImmutableVector;
let empty: [int, ..0] = []; let empty: [int, ..0] = [];
let xs = [1,2,3]; let xs = [1,2,3];

View file

@ -119,7 +119,7 @@ pub mod bool;
pub mod char; pub mod char;
pub mod tuple; pub mod tuple;
pub mod vec; pub mod slice;
pub mod vec_ng; pub mod vec_ng;
pub mod str; pub mod str;

View file

@ -42,7 +42,7 @@ local_data::get(key_vector, |opt| assert_eq!(*opt.unwrap(), ~[4]));
use cast; use cast;
use option::{None, Option, Some}; use option::{None, Option, Some};
use vec::{ImmutableVector, MutableVector, OwnedVector}; use slice::{ImmutableVector, MutableVector, OwnedVector};
use iter::{Iterator}; use iter::{Iterator};
use rt::task::{Task, LocalStorage}; use rt::task::{Task, LocalStorage};
use mem::replace; use mem::replace;

View file

@ -1727,12 +1727,12 @@ mod bench {
extern crate test; extern crate test;
use self::test::BenchHarness; use self::test::BenchHarness;
use num; use num;
use vec; use slice;
use prelude::*; use prelude::*;
#[bench] #[bench]
fn bench_pow_function(b: &mut BenchHarness) { 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));}); b.iter(|| {v.iter().fold(0, |old, new| num::pow(old, *new));});
} }
} }

View file

@ -18,8 +18,8 @@ use option::{None, Option, Some};
use char; use char;
use str::{StrSlice}; use str::{StrSlice};
use str; use str;
use vec::{CloneableVector, ImmutableVector, MutableVector}; use slice::{CloneableVector, ImmutableVector, MutableVector};
use vec::OwnedVector; use slice::OwnedVector;
use num; use num;
use num::{NumCast, Zero, One, cast, Int}; use num::{NumCast, Zero, One, cast, Int};
use num::{Round, Float, FPNaN, FPInfinite, ToPrimitive}; use num::{Round, Float, FPNaN, FPInfinite, ToPrimitive};

View file

@ -145,7 +145,7 @@ use default::Default;
use iter::{Iterator, DoubleEndedIterator, FromIterator, ExactSize}; use iter::{Iterator, DoubleEndedIterator, FromIterator, ExactSize};
use kinds::Send; use kinds::Send;
use mem; use mem;
use vec; use slice;
/// The `Option` /// The `Option`
#[deriving(Clone, Eq, Ord, TotalEq, TotalOrd, Show)] #[deriving(Clone, Eq, Ord, TotalEq, TotalOrd, Show)]
@ -215,7 +215,7 @@ impl<T> Option<T> {
#[inline] #[inline]
pub fn as_slice<'r>(&'r self) -> &'r [T] { pub fn as_slice<'r>(&'r self) -> &'r [T] {
match *self { match *self {
Some(ref x) => vec::ref_slice(x), Some(ref x) => slice::ref_slice(x),
None => &[] None => &[]
} }
} }
@ -224,7 +224,7 @@ impl<T> Option<T> {
#[inline] #[inline]
pub fn as_mut_slice<'r>(&'r mut self) -> &'r mut [T] { pub fn as_mut_slice<'r>(&'r mut self) -> &'r mut [T] {
match *self { match *self {
Some(ref mut x) => vec::mut_ref_slice(x), Some(ref mut x) => slice::mut_ref_slice(x),
None => &mut [] None => &mut []
} }
} }
@ -614,7 +614,7 @@ mod tests {
use iter::range; use iter::range;
use str::StrSlice; use str::StrSlice;
use kinds::marker; use kinds::marker;
use vec::ImmutableVector; use slice::ImmutableVector;
#[test] #[test]
fn test_get_ptr() { fn test_get_ptr() {

View file

@ -47,7 +47,7 @@ use fmt;
use sync::atomics::{AtomicInt, INIT_ATOMIC_INT, SeqCst}; use sync::atomics::{AtomicInt, INIT_ATOMIC_INT, SeqCst};
use path::{Path, GenericPath}; use path::{Path, GenericPath};
use iter::Iterator; use iter::Iterator;
use vec::{Vector, CloneableVector, ImmutableVector, MutableVector, OwnedVector}; use slice::{Vector, CloneableVector, ImmutableVector, MutableVector, OwnedVector};
use ptr::RawPtr; use ptr::RawPtr;
#[cfg(unix)] #[cfg(unix)]
@ -101,8 +101,8 @@ pub mod win32 {
use os::TMPBUF_SZ; use os::TMPBUF_SZ;
use str::StrSlice; use str::StrSlice;
use str; use str;
use vec::{MutableVector, ImmutableVector, OwnedVector}; use slice::{MutableVector, ImmutableVector, OwnedVector};
use vec; use slice;
pub fn fill_utf16_buf_and_decode(f: |*mut u16, DWORD| -> DWORD) pub fn fill_utf16_buf_and_decode(f: |*mut u16, DWORD| -> DWORD)
-> Option<~str> { -> Option<~str> {
@ -112,7 +112,7 @@ pub mod win32 {
let mut res = None; let mut res = None;
let mut done = false; let mut done = false;
while !done { 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); let k = f(buf.as_mut_ptr(), n);
if k == (0 as DWORD) { if k == (0 as DWORD) {
done = true; done = true;
@ -412,7 +412,7 @@ pub fn self_exe_name() -> Option<Path> {
unsafe { unsafe {
use libc::funcs::bsd44::*; use libc::funcs::bsd44::*;
use libc::consts::os::extra::*; use libc::consts::os::extra::*;
use vec; use slice;
let mib = ~[CTL_KERN as c_int, let mib = ~[CTL_KERN as c_int,
KERN_PROC as c_int, KERN_PROC as c_int,
KERN_PROC_PATHNAME as c_int, -1 as c_int]; KERN_PROC_PATHNAME as c_int, -1 as c_int];
@ -422,7 +422,7 @@ pub fn self_exe_name() -> Option<Path> {
0u as libc::size_t); 0u as libc::size_t);
if err != 0 { return None; } if err != 0 { return None; }
if sz == 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, let err = sysctl(mib.as_ptr(), mib.len() as ::libc::c_uint,
v.as_mut_ptr() as *mut c_void, &mut sz, ptr::null(), v.as_mut_ptr() as *mut c_void, &mut sz, ptr::null(),
0u as libc::size_t); 0u as libc::size_t);
@ -448,11 +448,11 @@ pub fn self_exe_name() -> Option<Path> {
fn load_self() -> Option<~[u8]> { fn load_self() -> Option<~[u8]> {
unsafe { unsafe {
use libc::funcs::extra::_NSGetExecutablePath; use libc::funcs::extra::_NSGetExecutablePath;
use vec; use slice;
let mut sz: u32 = 0; let mut sz: u32 = 0;
_NSGetExecutablePath(ptr::mut_null(), &mut sz); _NSGetExecutablePath(ptr::mut_null(), &mut sz);
if sz == 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 = _NSGetExecutablePath(v.as_mut_ptr() as *mut i8, &mut sz); let err = _NSGetExecutablePath(v.as_mut_ptr() as *mut i8, &mut sz);
if err != 0 { return None; } if err != 0 { return None; }
v.set_len(sz as uint - 1); // chop off trailing NUL v.set_len(sz as uint - 1); // chop off trailing NUL
@ -817,7 +817,7 @@ fn real_args() -> ~[~str] {
#[cfg(windows)] #[cfg(windows)]
fn real_args() -> ~[~str] { fn real_args() -> ~[~str] {
use vec; use slice;
let mut nArgs: c_int = 0; let mut nArgs: c_int = 0;
let lpArgCount: *mut c_int = &mut nArgs; let lpArgCount: *mut c_int = &mut nArgs;
@ -833,7 +833,7 @@ fn real_args() -> ~[~str] {
while *ptr.offset(len as int) != 0 { len += 1; } while *ptr.offset(len as int) != 0 { len += 1; }
// Push it onto the list. // 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)) str::from_utf16(str::truncate_utf16_at_nul(buf))
}); });
args.push(opt_s.expect("CommandLineToArgvW returned invalid UTF-16")); args.push(opt_s.expect("CommandLineToArgvW returned invalid UTF-16"));

View file

@ -71,9 +71,9 @@ use iter::Iterator;
use option::{Option, None, Some}; use option::{Option, None, Some};
use str; use str;
use str::{MaybeOwned, OwnedStr, Str, StrSlice, from_utf8_lossy}; use str::{MaybeOwned, OwnedStr, Str, StrSlice, from_utf8_lossy};
use vec; use slice;
use vec::{CloneableVector, OwnedCloneableVector, OwnedVector, Vector}; use slice::{CloneableVector, OwnedCloneableVector, OwnedVector, Vector};
use vec::{ImmutableEqVector, ImmutableVector}; use slice::{ImmutableEqVector, ImmutableVector};
/// Typedef for POSIX file paths. /// Typedef for POSIX file paths.
/// See `posix::Path` for more info. /// See `posix::Path` for more info.
@ -300,7 +300,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
} else { } else {
let mut v; let mut v;
let extension = extension.container_as_bytes(); 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_all(name);
v.push(dot); v.push(dot);
v.push_all(extension); v.push_all(extension);
@ -313,7 +313,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
} else { } else {
let mut v; let mut v;
let extension = extension.container_as_bytes(); 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(name.slice_to(idx+1));
v.push_all(extension); v.push_all(extension);
Some(v) Some(v)

View file

@ -20,9 +20,9 @@ use iter::{AdditiveIterator, Extendable, Iterator, Map};
use option::{Option, None, Some}; use option::{Option, None, Some};
use str; use str;
use str::Str; use str::Str;
use vec; use slice;
use vec::{CloneableVector, RevSplits, Splits, Vector, VectorVector, use slice::{CloneableVector, RevSplits, Splits, Vector, VectorVector,
ImmutableEqVector, OwnedVector, ImmutableVector, OwnedCloneableVector}; ImmutableEqVector, OwnedVector, ImmutableVector, OwnedCloneableVector};
use super::{BytesContainer, GenericPath, GenericPathUnsafe}; use super::{BytesContainer, GenericPath, GenericPathUnsafe};
/// Iterator that yields successive components of a Path as &[u8] /// Iterator that yields successive components of a Path as &[u8]
@ -125,7 +125,7 @@ impl GenericPathUnsafe for Path {
let filename = filename.container_as_bytes(); let filename = filename.container_as_bytes();
match self.sepidx { match self.sepidx {
None if bytes!("..") == self.repr => { 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_all(dot_dot_static);
v.push(SEP_BYTE); v.push(SEP_BYTE);
v.push_all(filename); v.push_all(filename);
@ -135,14 +135,14 @@ impl GenericPathUnsafe for Path {
self.repr = Path::normalize(filename); self.repr = Path::normalize(filename);
} }
Some(idx) if self.repr.slice_from(idx+1) == bytes!("..") => { 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_all(self.repr);
v.push(SEP_BYTE); v.push(SEP_BYTE);
v.push_all(filename); v.push_all(filename);
self.repr = Path::normalize(v); self.repr = Path::normalize(v);
} }
Some(idx) => { 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(self.repr.slice_to(idx+1));
v.push_all(filename); v.push_all(filename);
self.repr = Path::normalize(v); self.repr = Path::normalize(v);
@ -157,7 +157,7 @@ impl GenericPathUnsafe for Path {
if path[0] == SEP_BYTE { if path[0] == SEP_BYTE {
self.repr = Path::normalize(path); self.repr = Path::normalize(path);
} else { } 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_all(self.repr);
v.push(SEP_BYTE); v.push(SEP_BYTE);
v.push_all(path); v.push_all(path);
@ -346,7 +346,7 @@ impl Path {
} else { } else {
let n = if is_abs { comps.len() } else { comps.len() - 1} + let n = if is_abs { comps.len() } else { comps.len() - 1} +
comps.iter().map(|v| v.len()).sum(); 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(); let mut it = comps.move_iter();
if !is_abs { if !is_abs {
match it.next() { match it.next() {

View file

@ -22,7 +22,7 @@ use iter::{AdditiveIterator, DoubleEndedIterator, Extendable, Rev, Iterator, Map
use option::{Option, Some, None}; use option::{Option, Some, None};
use str; use str;
use str::{CharSplits, OwnedStr, Str, StrVector, StrSlice}; use str::{CharSplits, OwnedStr, Str, StrVector, StrSlice};
use vec::{Vector, OwnedVector, ImmutableVector}; use slice::{Vector, OwnedVector, ImmutableVector};
use super::{contains_nul, BytesContainer, GenericPath, GenericPathUnsafe}; use super::{contains_nul, BytesContainer, GenericPath, GenericPathUnsafe};
/// Iterator that yields successive components of a Path as &str /// Iterator that yields successive components of a Path as &str

View file

@ -55,10 +55,10 @@ pub use to_str::{ToStr, IntoStr};
pub use tuple::{Tuple1, Tuple2, Tuple3, Tuple4}; pub use tuple::{Tuple1, Tuple2, Tuple3, Tuple4};
pub use tuple::{Tuple5, Tuple6, Tuple7, Tuple8}; pub use tuple::{Tuple5, Tuple6, Tuple7, Tuple8};
pub use tuple::{Tuple9, Tuple10, Tuple11, Tuple12}; pub use tuple::{Tuple9, Tuple10, Tuple11, Tuple12};
pub use vec::{ImmutableEqVector, ImmutableTotalOrdVector, ImmutableCloneableVector}; pub use slice::{ImmutableEqVector, ImmutableTotalOrdVector, ImmutableCloneableVector};
pub use vec::{OwnedVector, OwnedCloneableVector, OwnedEqVector}; pub use slice::{OwnedVector, OwnedCloneableVector, OwnedEqVector};
pub use vec::{MutableVector, MutableTotalOrdVector}; pub use slice::{MutableVector, MutableTotalOrdVector};
pub use vec::{Vector, VectorVector, CloneableVector, ImmutableVector}; pub use slice::{Vector, VectorVector, CloneableVector, ImmutableVector};
// Reexported runtime types // Reexported runtime types
pub use comm::{channel, Sender, Receiver}; pub use comm::{channel, Sender, Receiver};

View file

@ -388,7 +388,7 @@ pub mod ptr_tests {
use cast; use cast;
use libc; use libc;
use str; use str;
use vec::{ImmutableVector, MutableVector}; use slice::{ImmutableVector, MutableVector};
#[test] #[test]
fn test() { fn test() {

View file

@ -28,7 +28,7 @@ use reflect::{MovePtr, align};
use result::{Ok, Err}; use result::{Ok, Err};
use str::StrSlice; use str::StrSlice;
use to_str::ToStr; use to_str::ToStr;
use vec::OwnedVector; use slice::OwnedVector;
use intrinsics::{Disr, Opaque, TyDesc, TyVisitor, get_tydesc, visit_tydesc}; use intrinsics::{Disr, Opaque, TyDesc, TyVisitor, get_tydesc, visit_tydesc};
use raw; use raw;

View file

@ -124,10 +124,10 @@ mod imp {
#[cfg(not(test))] #[cfg(not(test))]
unsafe fn load_argc_and_argv(argc: int, argv: **u8) -> ~[~[u8]] { unsafe fn load_argc_and_argv(argc: int, argv: **u8) -> ~[~[u8]] {
use c_str::CString; use c_str::CString;
use {vec, libc}; use {slice, libc};
use vec::CloneableVector; 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); let cs = CString::new(*(argv as **libc::c_char).offset(i as int), false);
cs.as_bytes_no_nul().to_owned() cs.as_bytes_no_nul().to_owned()
}) })

View file

@ -18,7 +18,7 @@ use mem;
use option::{Some, None}; use option::{Some, None};
use ptr::RawPtr; use ptr::RawPtr;
use unstable::sync::Exclusive; use unstable::sync::Exclusive;
use vec::OwnedVector; use slice::OwnedVector;
type Queue = Exclusive<~[proc()]>; type Queue = Exclusive<~[proc()]>;

View file

@ -349,7 +349,7 @@ mod imp {
use path::GenericPath; use path::GenericPath;
use ptr::RawPtr; use ptr::RawPtr;
use ptr; use ptr;
use vec::{ImmutableVector, MutableVector}; use slice::{ImmutableVector, MutableVector};
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// libbacktrace.h API // libbacktrace.h API
@ -510,7 +510,7 @@ mod imp {
use unstable::dynamic_lib::DynamicLibrary; use unstable::dynamic_lib::DynamicLibrary;
use intrinsics; use intrinsics;
use unstable::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT}; use unstable::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
use vec::ImmutableVector; use slice::ImmutableVector;
extern "system" { extern "system" {
fn GetCurrentProcess() -> libc::HANDLE; fn GetCurrentProcess() -> libc::HANDLE;

View file

@ -16,7 +16,7 @@ use rt::rtio::EventLoop;
#[cfg(stage0)] use cmp::TotalOrd; #[cfg(stage0)] use cmp::TotalOrd;
#[cfg(stage0)] use container::MutableSet; #[cfg(stage0)] use container::MutableSet;
#[cfg(stage0)] use iter::Iterator; #[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 // 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 // and instead look them up at runtime, which we need to resolve

View file

@ -21,7 +21,7 @@ use rt::global_heap;
use rt::local::Local; use rt::local::Local;
use rt::task::Task; use rt::task::Task;
use raw; use raw;
use vec::ImmutableVector; use slice::ImmutableVector;
use vec_ng::Vec; use vec_ng::Vec;
// This has no meaning with out rtdebug also turned on. // This has no meaning with out rtdebug also turned on.

View file

@ -20,7 +20,7 @@ use os;
use result::Ok; use result::Ok;
use str::StrSlice; use str::StrSlice;
use unstable::running_on_valgrind; use unstable::running_on_valgrind;
use vec::ImmutableVector; use slice::ImmutableVector;
// Indicates whether we should perform expensive sanity checks, including rtassert! // Indicates whether we should perform expensive sanity checks, including rtassert!
// FIXME: Once the runtime matures remove the `true` below to turn off rtassert, etc. // FIXME: Once the runtime matures remove the `true` below to turn off rtassert, etc.

View file

@ -158,7 +158,7 @@ pub fn from_elem<T:Clone>(n_elts: uint, t: T) -> ~[T] {
// FIXME (#7136): manually inline from_fn for 2x plus speedup (sadly very // FIXME (#7136): manually inline from_fn for 2x plus speedup (sadly very
// important, from_elem is a bottleneck in borrowck!). Unfortunately it // important, from_elem is a bottleneck in borrowck!). Unfortunately it
// still is substantially slower than using the unsafe // 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 { unsafe {
let mut v = with_capacity(n_elts); let mut v = with_capacity(n_elts);
let p = v.as_mut_ptr(); let p = v.as_mut_ptr();
@ -1464,7 +1464,7 @@ impl<T> OwnedVector<T> for ~[T] {
fn reserve_additional(&mut self, n: uint) { fn reserve_additional(&mut self, n: uint) {
if self.capacity() - self.len() < n { if self.capacity() - self.len() < n {
match self.len().checked_add(&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) Some(new_cap) => self.reserve(new_cap)
} }
} }
@ -2430,7 +2430,7 @@ pub trait MutableCloneableVector<T> {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// use std::vec::MutableCloneableVector; /// use std::slice::MutableCloneableVector;
/// ///
/// let mut dst = [0, 0, 0]; /// let mut dst = [0, 0, 0];
/// let src = [1, 2]; /// let src = [1, 2];
@ -2497,7 +2497,7 @@ pub mod raw {
use cast::transmute; use cast::transmute;
use ptr; use ptr;
use ptr::RawPtr; use ptr::RawPtr;
use vec::{with_capacity, MutableVector, OwnedVector}; use slice::{with_capacity, MutableVector, OwnedVector};
use raw::Slice; use raw::Slice;
/** /**
@ -2576,7 +2576,7 @@ pub mod raw {
/// Operations on `[u8]`. /// Operations on `[u8]`.
pub mod bytes { pub mod bytes {
use container::Container; use container::Container;
use vec::{MutableVector, OwnedVector, ImmutableVector}; use slice::{MutableVector, OwnedVector, ImmutableVector};
use ptr; use ptr;
use ptr::RawPtr; use ptr::RawPtr;
@ -2952,7 +2952,7 @@ impl<A> Extendable<A> for ~[A] {
mod tests { mod tests {
use prelude::*; use prelude::*;
use mem; use mem;
use vec::*; use slice::*;
use cmp::*; use cmp::*;
use rand::{Rng, task_rng}; use rand::{Rng, task_rng};
@ -4105,7 +4105,7 @@ mod tests {
#[test] #[test]
fn test_bytes_set_memory() { fn test_bytes_set_memory() {
use vec::bytes::MutableByteVector; use slice::bytes::MutableByteVector;
let mut values = [1u8,2,3,4,5]; let mut values = [1u8,2,3,4,5];
values.mut_slice(0,5).set_memory(0xAB); values.mut_slice(0,5).set_memory(0xAB);
assert!(values == [0xAB, 0xAB, 0xAB, 0xAB, 0xAB]); assert!(values == [0xAB, 0xAB, 0xAB, 0xAB, 0xAB]);
@ -4185,11 +4185,11 @@ mod tests {
let xs = ~[Foo, Foo, Foo]; let xs = ~[Foo, Foo, Foo];
assert_eq!(format!("{:?}", xs.slice(0, 2).to_owned()), 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]; let xs: [Foo, ..3] = [Foo, Foo, Foo];
assert_eq!(format!("{:?}", xs.slice(0, 2).to_owned()), assert_eq!(format!("{:?}", xs.slice(0, 2).to_owned()),
~"~[vec::tests::Foo, vec::tests::Foo]"); ~"~[slice::tests::Foo, slice::tests::Foo]");
cnt = 0; cnt = 0;
for f in xs.iter() { for f in xs.iter() {
assert!(*f == Foo); assert!(*f == Foo);
@ -4365,13 +4365,13 @@ mod bench {
use prelude::*; use prelude::*;
use ptr; use ptr;
use rand::{weak_rng, Rng}; use rand::{weak_rng, Rng};
use vec; use slice;
#[bench] #[bench]
fn iterator(bh: &mut BenchHarness) { fn iterator(bh: &mut BenchHarness) {
// peculiar numbers to stop LLVM from optimising the summation // peculiar numbers to stop LLVM from optimising the summation
// out. // 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(|| { bh.iter(|| {
let mut sum = 0; let mut sum = 0;
@ -4385,7 +4385,7 @@ mod bench {
#[bench] #[bench]
fn mut_iterator(bh: &mut BenchHarness) { fn mut_iterator(bh: &mut BenchHarness) {
let mut v = vec::from_elem(100, 0); let mut v = slice::from_elem(100, 0);
bh.iter(|| { bh.iter(|| {
let mut i = 0; let mut i = 0;
@ -4407,7 +4407,7 @@ mod bench {
#[bench] #[bench]
fn concat(bh: &mut BenchHarness) { 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(|| { bh.iter(|| {
let _ = xss.concat_vec(); let _ = xss.concat_vec();
}); });
@ -4415,7 +4415,7 @@ mod bench {
#[bench] #[bench]
fn connect(bh: &mut BenchHarness) { 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(|| { bh.iter(|| {
let _ = xss.connect_vec(&0); let _ = xss.connect_vec(&0);
}); });
@ -4432,7 +4432,7 @@ mod bench {
#[bench] #[bench]
fn starts_with_same_vector(bh: &mut BenchHarness) { 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(|| { bh.iter(|| {
vec.starts_with(vec) vec.starts_with(vec)
}) })
@ -4448,8 +4448,8 @@ mod bench {
#[bench] #[bench]
fn starts_with_diff_one_element_at_end(bh: &mut BenchHarness) { fn starts_with_diff_one_element_at_end(bh: &mut BenchHarness) {
let vec: ~[uint] = vec::from_fn(100, |i| i); let vec: ~[uint] = slice::from_fn(100, |i| i);
let mut match_vec: ~[uint] = vec::from_fn(99, |i| i); let mut match_vec: ~[uint] = slice::from_fn(99, |i| i);
match_vec.push(0); match_vec.push(0);
bh.iter(|| { bh.iter(|| {
vec.starts_with(match_vec) vec.starts_with(match_vec)
@ -4458,7 +4458,7 @@ mod bench {
#[bench] #[bench]
fn ends_with_same_vector(bh: &mut BenchHarness) { 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(|| { bh.iter(|| {
vec.ends_with(vec) vec.ends_with(vec)
}) })
@ -4474,8 +4474,8 @@ mod bench {
#[bench] #[bench]
fn ends_with_diff_one_element_at_beginning(bh: &mut BenchHarness) { fn ends_with_diff_one_element_at_beginning(bh: &mut BenchHarness) {
let vec: ~[uint] = vec::from_fn(100, |i| i); let vec: ~[uint] = slice::from_fn(100, |i| i);
let mut match_vec: ~[uint] = vec::from_fn(100, |i| i); let mut match_vec: ~[uint] = slice::from_fn(100, |i| i);
match_vec[0] = 200; match_vec[0] = 200;
bh.iter(|| { bh.iter(|| {
vec.starts_with(match_vec) vec.starts_with(match_vec)
@ -4484,7 +4484,7 @@ mod bench {
#[bench] #[bench]
fn contains_last_element(bh: &mut BenchHarness) { 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(|| { bh.iter(|| {
vec.contains(&99u) vec.contains(&99u)
}) })
@ -4493,14 +4493,14 @@ mod bench {
#[bench] #[bench]
fn zero_1kb_from_elem(bh: &mut BenchHarness) { fn zero_1kb_from_elem(bh: &mut BenchHarness) {
bh.iter(|| { bh.iter(|| {
let _v: ~[u8] = vec::from_elem(1024, 0u8); let _v: ~[u8] = slice::from_elem(1024, 0u8);
}); });
} }
#[bench] #[bench]
fn zero_1kb_set_memory(bh: &mut BenchHarness) { fn zero_1kb_set_memory(bh: &mut BenchHarness) {
bh.iter(|| { bh.iter(|| {
let mut v: ~[u8] = vec::with_capacity(1024); let mut v: ~[u8] = slice::with_capacity(1024);
unsafe { unsafe {
let vp = v.as_mut_ptr(); let vp = v.as_mut_ptr();
ptr::set_memory(vp, 0, 1024); 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 // 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. // field to be aliased (in theory) and prevents LLVM from optimizing loads away.
bh.iter(|| { bh.iter(|| {
let mut v: ~[u8] = vec::with_capacity(1024); let mut v: ~[u8] = slice::with_capacity(1024);
unsafe { unsafe {
v.set_len(1024); v.set_len(1024);
} }
@ -4535,7 +4535,7 @@ mod bench {
#[bench] #[bench]
fn zero_1kb_mut_iter(bh: &mut BenchHarness) { fn zero_1kb_mut_iter(bh: &mut BenchHarness) {
bh.iter(|| { bh.iter(|| {
let mut v: ~[u8] = vec::with_capacity(1024); let mut v: ~[u8] = slice::with_capacity(1024);
unsafe { unsafe {
v.set_len(1024); v.set_len(1024);
} }
@ -4550,7 +4550,7 @@ mod bench {
fn random_inserts(bh: &mut BenchHarness) { fn random_inserts(bh: &mut BenchHarness) {
let mut rng = weak_rng(); let mut rng = weak_rng();
bh.iter(|| { 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) { for _ in range(0, 100) {
let l = v.len(); let l = v.len();
v.insert(rng.gen::<uint>() % (l + 1), v.insert(rng.gen::<uint>() % (l + 1),
@ -4562,7 +4562,7 @@ mod bench {
fn random_removes(bh: &mut BenchHarness) { fn random_removes(bh: &mut BenchHarness) {
let mut rng = weak_rng(); let mut rng = weak_rng();
bh.iter(|| { 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) { for _ in range(0, 100) {
let l = v.len(); let l = v.len();
v.remove(rng.gen::<uint>() % l); v.remove(rng.gen::<uint>() % l);
@ -4602,7 +4602,7 @@ mod bench {
#[bench] #[bench]
fn sort_sorted(bh: &mut BenchHarness) { 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(|| { bh.iter(|| {
v.sort(); v.sort();
}); });
@ -4643,7 +4643,7 @@ mod bench {
#[bench] #[bench]
fn sort_big_sorted(bh: &mut BenchHarness) { 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(|| { bh.iter(|| {
v.sort(); v.sort();
}); });

View file

@ -99,8 +99,8 @@ use option::{None, Option, Some};
use ptr; use ptr;
use ptr::RawPtr; use ptr::RawPtr;
use from_str::FromStr; use from_str::FromStr;
use vec; use slice;
use vec::{OwnedVector, OwnedCloneableVector, ImmutableVector, MutableVector}; use slice::{OwnedVector, OwnedCloneableVector, ImmutableVector, MutableVector};
use vec_ng::Vec; use vec_ng::Vec;
use default::Default; use default::Default;
use raw::Repr; use raw::Repr;
@ -360,7 +360,7 @@ pub type RevCharOffsets<'a> = Rev<CharOffsets<'a>>;
/// External iterator for a string's bytes. /// External iterator for a string's bytes.
/// Use with the `std::iter` module. /// Use with the `std::iter` module.
pub type Bytes<'a> = 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. /// External iterator for a string's bytes in reverse order.
/// Use with the `std::iter` module. /// 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 /// `iter` reset such that it is pointing at the first byte in the
/// invalid sequence. /// invalid sequence.
#[inline(always)] #[inline(always)]
fn run_utf8_validation_iterator(iter: &mut vec::Items<u8>) -> bool { fn run_utf8_validation_iterator(iter: &mut slice::Items<u8>) -> bool {
loop { loop {
// save the current thing we're pointing at. // save the current thing we're pointing at.
let old = *iter; let old = *iter;
@ -855,7 +855,7 @@ pub fn is_utf16(v: &[u16]) -> bool {
/// of `u16`s. /// of `u16`s.
#[deriving(Clone)] #[deriving(Clone)]
pub struct UTF16Items<'a> { 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. /// The possibilities for values decoded from a `u16` stream.
#[deriving(Eq, TotalEq, Clone, Show)] #[deriving(Eq, TotalEq, Clone, Show)]
@ -1025,7 +1025,7 @@ pub fn from_utf16_lossy(v: &[u16]) -> ~str {
#[inline] #[inline]
pub fn with_capacity(capacity: uint) -> ~str { pub fn with_capacity(capacity: uint) -> ~str {
unsafe { 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 ptr::RawPtr;
use option::{Option, Some, None}; use option::{Option, Some, None};
use str::{is_utf8, OwnedStr, StrSlice}; use str::{is_utf8, OwnedStr, StrSlice};
use vec; use slice;
use vec::{MutableVector, ImmutableVector, OwnedVector}; use slice::{MutableVector, ImmutableVector, OwnedVector};
use raw::Slice; use raw::Slice;
/// Create a Rust string from a *u8 buffer of the given length /// Create a Rust string from a *u8 buffer of the given length
pub unsafe fn from_buf_len(buf: *u8, len: uint) -> ~str { 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); ptr::copy_memory(v.as_mut_ptr(), buf, len);
v.set_len(len); v.set_len(len);
@ -1463,7 +1463,7 @@ pub mod raw {
/// The caller must preserve the valid UTF-8 property. /// The caller must preserve the valid UTF-8 property.
#[inline] #[inline]
pub unsafe fn push_bytes(s: &mut ~str, bytes: &[u8]) { 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. /// 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 { fn to_owned(&self) -> ~str {
let len = self.len(); let len = self.len();
unsafe { 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); ptr::copy_memory(v.as_mut_ptr(), self.as_ptr(), len);
v.set_len(len); v.set_len(len);
@ -2766,7 +2766,7 @@ impl<'a> StrSlice<'a> for &'a str {
if slen == 0 { return tlen; } if slen == 0 { return tlen; }
if tlen == 0 { return slen; } 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() { 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 // Attempt to not use an intermediate buffer by just pushing bytes
// directly onto this string. // directly onto this string.
let write_ptr = v.as_mut_ptr().offset(cur_len as int); 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); v.set_len(cur_len + used);
} }
@ -4667,7 +4667,7 @@ mod bench {
#[bench] #[bench]
fn from_utf8_lossy_100_invalid(bh: &mut BenchHarness) { 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(|| { bh.iter(|| {
let _ = from_utf8_lossy(s); let _ = from_utf8_lossy(s);
}); });

View file

@ -27,7 +27,7 @@ use kinds::Send;
use ops::Drop; use ops::Drop;
use ptr::RawPtr; use ptr::RawPtr;
use sync::atomics::{fence, AtomicUint, Relaxed, Acquire, Release}; use sync::atomics::{fence, AtomicUint, Relaxed, Acquire, Release};
use vec; use slice;
/// An atomically reference counted pointer. /// An atomically reference counted pointer.
/// ///
@ -69,7 +69,7 @@ impl<T: Send> UnsafeArc<T> {
~[] // need to free data here ~[] // need to free data here
} else { } else {
let ptr = new_inner(data, num_handles); let ptr = new_inner(data, num_handles);
vec::from_fn(num_handles, |_| UnsafeArc { data: ptr }) slice::from_fn(num_handles, |_| UnsafeArc { data: ptr })
} }
} }
} }

View file

@ -61,7 +61,7 @@ use ptr::RawPtr;
use sync::arc::UnsafeArc; use sync::arc::UnsafeArc;
use sync::atomics::{AtomicInt, AtomicPtr, SeqCst}; use sync::atomics::{AtomicInt, AtomicPtr, SeqCst};
use unstable::sync::Exclusive; 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 // 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. // the deque requires that this number be less than 2.
@ -404,7 +404,7 @@ mod tests {
use rand::Rng; use rand::Rng;
use sync::atomics::{AtomicBool, INIT_ATOMIC_BOOL, SeqCst, use sync::atomics::{AtomicBool, INIT_ATOMIC_BOOL, SeqCst,
AtomicUint, INIT_ATOMIC_UINT}; AtomicUint, INIT_ATOMIC_UINT};
use vec; use slice;
#[test] #[test]
fn smoke() { fn smoke() {
@ -600,7 +600,7 @@ mod tests {
let mut pool = BufferPool::<(int, uint)>::new(); let mut pool = BufferPool::<(int, uint)>::new();
let (mut w, s) = pool.deque(); 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 s = s.clone();
let unique_box = ~AtomicUint::new(0); let unique_box = ~AtomicUint::new(0);
let thread_box = unsafe { let thread_box = unsafe {

View file

@ -35,7 +35,7 @@ use num::next_power_of_two;
use option::{Option, Some, None}; use option::{Option, Some, None};
use sync::arc::UnsafeArc; use sync::arc::UnsafeArc;
use sync::atomics::{AtomicUint,Relaxed,Release,Acquire}; use sync::atomics::{AtomicUint,Relaxed,Release,Acquire};
use vec; use slice;
struct Node<T> { struct Node<T> {
sequence: AtomicUint, sequence: AtomicUint,
@ -69,8 +69,8 @@ impl<T: Send> State<T> {
} else { } else {
capacity capacity
}; };
let buffer = vec::from_fn(capacity, |i:uint| { let buffer = slice::from_fn(capacity, |i| {
Node{sequence:AtomicUint::new(i),value:None} Node { sequence:AtomicUint::new(i), value: None }
}); });
State{ State{
pad0: [0, ..64], pad0: [0, ..64],

View file

@ -13,10 +13,9 @@
#[allow(missing_doc)]; #[allow(missing_doc)];
#[allow(non_uppercase_statics)]; #[allow(non_uppercase_statics)];
fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool { fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool {
use cmp::{Equal, Less, Greater}; use cmp::{Equal, Less, Greater};
use vec::ImmutableVector; use slice::ImmutableVector;
use option::None; use option::None;
r.bsearch(|&(lo,hi)| { r.bsearch(|&(lo,hi)| {
if lo <= c && c <= hi { Equal } if lo <= c && c <= hi { Equal }
@ -25,7 +24,6 @@ fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool {
}) != None }) != None
} }
pub mod general_category { pub mod general_category {
static Cc_table : &'static [(char,char)] = &[ static Cc_table : &'static [(char,char)] = &[
('\x00', '\x1f'), ('\x7f', '\x9f') ('\x00', '\x1f'), ('\x7f', '\x9f')
@ -108,7 +106,7 @@ pub mod general_category {
pub mod decompose { pub mod decompose {
use option::Option; use option::Option;
use option::{Some, None}; use option::{Some, None};
use vec::ImmutableVector; use slice::ImmutableVector;
fn bsearch_table(c: char, r: &'static [(char, &'static [char])]) -> Option<&'static [char]> { fn bsearch_table(c: char, r: &'static [(char, &'static [char])]) -> Option<&'static [char]> {
use cmp::{Equal, Less, Greater}; use cmp::{Equal, Less, Greater};
@ -4136,8 +4134,8 @@ pub mod derived_property {
pub fn XID_Start(c: char) -> bool { pub fn XID_Start(c: char) -> bool {
super::bsearch_range_table(c, XID_Start_table) super::bsearch_range_table(c, XID_Start_table)
} }
} }
pub mod property { pub mod property {
static White_Space_table : &'static [(char,char)] = &[ static White_Space_table : &'static [(char,char)] = &[
('\x09', '\x0d'), ('\x20', '\x20'), ('\x09', '\x0d'), ('\x20', '\x20'),
@ -4151,12 +4149,11 @@ pub mod property {
pub fn White_Space(c: char) -> bool { pub fn White_Space(c: char) -> bool {
super::bsearch_range_table(c, White_Space_table) super::bsearch_range_table(c, White_Space_table)
} }
} }
pub mod conversions {
pub mod conversions {
use cmp::{Equal, Less, Greater}; use cmp::{Equal, Less, Greater};
use vec::ImmutableVector; use slice::ImmutableVector;
use tuple::Tuple2; use tuple::Tuple2;
use option::{Option, Some, None}; use option::{Option, Some, None};
@ -4181,7 +4178,8 @@ pub mod conversions {
else { Greater } else { Greater }
}) })
} }
static LuLl_table : &'static [(char, char)] = &[
static LuLl_table : &'static [(char, char)] = &[
('\x41', '\x61'), ('\x42', '\x62'), ('\x41', '\x61'), ('\x42', '\x62'),
('\x43', '\x63'), ('\x44', '\x64'), ('\x43', '\x63'), ('\x44', '\x64'),
('\x45', '\x65'), ('\x46', '\x66'), ('\x45', '\x65'), ('\x46', '\x66'),

View file

@ -27,8 +27,8 @@ use ptr::RawPtr;
use ptr; use ptr;
use rt::global_heap::{malloc_raw, realloc_raw}; use rt::global_heap::{malloc_raw, realloc_raw};
use raw::Slice; use raw::Slice;
use vec::{ImmutableEqVector, ImmutableVector, Items, MutItems, MutableVector}; use slice::{ImmutableEqVector, ImmutableVector, Items, MutItems, MutableVector};
use vec::{MutableTotalOrdVector}; use slice::{MutableTotalOrdVector};
/// An owned, growable vector /// An owned, growable vector
/// ///

View file

@ -21,11 +21,11 @@
* extern crate sync; * extern crate sync;
* extern crate rand; * extern crate rand;
* *
* use std::vec; * use std::slice;
* use sync::Arc; * use sync::Arc;
* *
* fn main() { * 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); * let shared_numbers = Arc::new(numbers);
* *
* for _ in range(0, 10) { * for _ in range(0, 10) {

View file

@ -13,9 +13,8 @@
/// A task pool abstraction. Useful for achieving predictable CPU /// A task pool abstraction. Useful for achieving predictable CPU
/// parallelism. /// parallelism.
use std::task; use std::task;
use std::vec; use std::slice;
enum Msg<T> { enum Msg<T> {
Execute(proc(&T)), Execute(proc(&T)),
@ -47,7 +46,7 @@ impl<T> TaskPool<T> {
-> TaskPool<T> { -> TaskPool<T> {
assert!(n_tasks >= 1); assert!(n_tasks >= 1);
let channels = vec::from_fn(n_tasks, |i| { let channels = slice::from_fn(n_tasks, |i| {
let (tx, rx) = channel::<Msg<T>>(); let (tx, rx) = channel::<Msg<T>>();
let init_fn = init_fn_factory(); let init_fn = init_fn_factory();

View file

@ -520,7 +520,7 @@ pub enum Expr_ {
ExprIndex(@Expr, @Expr), ExprIndex(@Expr, @Expr),
/// Expression that looks like a "name". For example, /// Expression that looks like a "name". For example,
/// `std::vec::from_elem::<uint>` is an ExprPath that's the "name" part /// `std::slice::from_elem::<uint>` is an ExprPath that's the "name" part
/// of a function call. /// of a function call.
ExprPath(Path), ExprPath(Path),

View file

@ -20,7 +20,7 @@ use util::small_vector::SmallVector;
use std::cell::RefCell; use std::cell::RefCell;
use std::iter; use std::iter;
use std::vec; use std::slice;
use std::fmt; use std::fmt;
use std::vec_ng::Vec; use std::vec_ng::Vec;
@ -65,9 +65,9 @@ impl<'a> Iterator<PathElem> 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)] #[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<T> for Values<'a, T> { impl<'a, T: Pod> Iterator<T> for Values<'a, T> {
fn next(&mut self) -> Option<T> { fn next(&mut self) -> Option<T> {

View file

@ -20,7 +20,7 @@ use rsparse = parse;
use std::fmt::parse; use std::fmt::parse;
use collections::{HashMap, HashSet}; use collections::{HashMap, HashSet};
use std::vec; use std::slice;
use std::vec_ng::Vec; use std::vec_ng::Vec;
#[deriving(Eq)] #[deriving(Eq)]
@ -610,7 +610,7 @@ impl<'a, 'b> Context<'a, 'b> {
fn to_expr(&self, extra: @ast::Expr) -> @ast::Expr { fn to_expr(&self, extra: @ast::Expr) -> @ast::Expr {
let mut lets = Vec::new(); let mut lets = Vec::new();
let mut locals = 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 pats = Vec::new();
let mut heads = Vec::new(); let mut heads = Vec::new();

View file

@ -16,7 +16,7 @@
*/ */
use std::default::Default; use std::default::Default;
use std::vec; use std::slice;
use std::vec_ng::Vec; use std::vec_ng::Vec;
#[deriving(Clone, Encodable, Decodable, Hash)] #[deriving(Clone, Encodable, Decodable, Hash)]
@ -176,7 +176,7 @@ impl<T> Default for OptVec<T> {
} }
pub struct Items<'a, T> { pub struct Items<'a, T> {
priv iter: Option<vec::Items<'a, T>> priv iter: Option<slice::Items<'a, T>>
} }
impl<'a, T> Iterator<&'a T> for Items<'a, T> { impl<'a, T> Iterator<&'a T> for Items<'a, T> {

View file

@ -10,7 +10,7 @@
//! Parameterized string expansion //! Parameterized string expansion
use std::{char, vec}; use std::{char, slice};
use std::mem::replace; use std::mem::replace;
#[deriving(Eq)] #[deriving(Eq)]
@ -93,7 +93,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
let mut state = Nothing; let mut state = Nothing;
// expanded cap will only rarely be larger than the cap itself // 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] = ~[]; 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"), (FormatString, _) => return Err(~"non-number on stack with %s"),
}; };
if flags.precision > s.len() { 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(); let n = flags.precision - s.len();
s_.grow(n, &('0' as u8)); s_.grow(n, &('0' as u8));
s_.push_all_move(s); s_.push_all_move(s);
@ -543,7 +543,7 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<~[u8],~str> {
if flags.left { if flags.left {
s.grow(n, &(' ' as u8)); s.grow(n, &(' ' as u8));
} else { } else {
let mut s_ = vec::with_capacity(flags.width); let mut s_ = slice::with_capacity(flags.width);
s_.grow(n, &(' ' as u8)); s_.grow(n, &(' ' as u8));
s_.push_all_move(s); s_.push_all_move(s);
s = s_; s = s_;

View file

@ -13,7 +13,7 @@
/// ncurses-compatible compiled terminfo format parsing (term(5)) /// ncurses-compatible compiled terminfo format parsing (term(5))
use std::{vec, str}; use std::{slice, str};
use std::io; use std::io;
use collections::HashMap; use collections::HashMap;
use super::super::TermInfo; use super::super::TermInfo;
@ -246,7 +246,7 @@ pub fn parse(file: &mut io::Reader,
let mut string_map = HashMap::new(); let mut string_map = HashMap::new();
if string_offsets_count != 0 { 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) { for _ in range(0, string_offsets_count) {
string_offsets.push(try!(file.read_le_u16())); string_offsets.push(try!(file.read_le_u16()));
} }

View file

@ -1035,7 +1035,7 @@ mod tests {
#[cfg(test)] #[cfg(test)]
mod bench { mod bench {
use BenchHarness; use BenchHarness;
use std::vec; use std::slice;
use stats::Stats; use stats::Stats;
#[bench] #[bench]
@ -1047,7 +1047,7 @@ mod bench {
#[bench] #[bench]
pub fn sum_many_f64(bh: &mut BenchHarness) { pub fn sum_many_f64(bh: &mut BenchHarness) {
let nums = [-1e30, 1e60, 1e30, 1.0, -1e60]; 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(|| { bh.iter(|| {
v.sum(); v.sum();

View file

@ -85,7 +85,7 @@ use std::from_str::FromStr;
use std::hash::Hash; use std::hash::Hash;
use std::num::FromStrRadix; use std::num::FromStrRadix;
use std::str; use std::str;
use std::vec; use std::slice;
use rand::Rng; use rand::Rng;
@ -202,7 +202,7 @@ impl Uuid {
pub fn new_v4() -> Uuid { pub fn new_v4() -> Uuid {
let ub = rand::task_rng().gen_vec(16); let ub = rand::task_rng().gen_vec(16);
let mut uuid = Uuid{ bytes: [0, .. 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_variant(VariantRFC4122);
uuid.set_version(Version4Random); uuid.set_version(Version4Random);
uuid uuid
@ -229,7 +229,7 @@ impl Uuid {
fields.data1 = to_be32(d1 as i32) as u32; fields.data1 = to_be32(d1 as i32) as u32;
fields.data2 = to_be16(d2 as i16) as u16; fields.data2 = to_be16(d2 as i16) as u16;
fields.data3 = to_be16(d3 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 { unsafe {
transmute(fields) transmute(fields)
@ -246,7 +246,7 @@ impl Uuid {
} }
let mut uuid = Uuid{ bytes: [0, .. 16] }; let mut uuid = Uuid{ bytes: [0, .. 16] };
vec::bytes::copy_memory(uuid.bytes, b); slice::bytes::copy_memory(uuid.bytes, b);
Some(uuid) Some(uuid)
} }
@ -329,7 +329,7 @@ impl Uuid {
/// ///
/// Example: `936DA01F9ABD4d9d80C702AF85C822A8` /// Example: `936DA01F9ABD4d9d80C702AF85C822A8`
pub fn to_simple_str(&self) -> ~str { 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) { for i in range(0u, 16u) {
let digit = format!("{:02x}", self.bytes[i] as uint); let digit = format!("{:02x}", self.bytes[i] as uint);
s[i*2+0] = digit[0]; s[i*2+0] = digit[0];
@ -523,7 +523,7 @@ impl rand::Rand for Uuid {
fn rand<R: rand::Rng>(rng: &mut R) -> Uuid { fn rand<R: rand::Rng>(rng: &mut R) -> Uuid {
let ub = rng.gen_vec(16); let ub = rng.gen_vec(16);
let mut uuid = Uuid{ bytes: [0, .. 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_variant(VariantRFC4122);
uuid.set_version(Version4Random); uuid.set_version(Version4Random);
uuid uuid

View file

@ -16,7 +16,7 @@ use collections::{TrieMap, TreeMap, HashMap, HashSet};
use std::os; use std::os;
use rand::{Rng, IsaacRng, SeedableRng}; use rand::{Rng, IsaacRng, SeedableRng};
use std::uint; use std::uint;
use std::vec; use std::slice;
fn timed(label: &str, f: ||) { fn timed(label: &str, f: ||) {
let start = time::precise_time_s(); 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]); let mut rng: IsaacRng = SeedableRng::from_seed(&[1, 1, 1, 1, 1, 1, 1]);

View file

@ -20,7 +20,7 @@ use rand::Rng;
use std::mem::swap; use std::mem::swap;
use std::os; use std::os;
use std::str; use std::str;
use std::vec; use std::slice;
use std::io::File; use std::io::File;
macro_rules! bench ( macro_rules! bench (
@ -61,7 +61,7 @@ fn maybe_run_test(argv: &[~str], name: ~str, test: ||) {
} }
fn shift_push() { fn shift_push() {
let mut v1 = vec::from_elem(30000, 1); let mut v1 = slice::from_elem(30000, 1);
let mut v2 = ~[]; let mut v2 = ~[];
while v1.len() > 0 { while v1.len() > 0 {
@ -88,7 +88,7 @@ fn vec_plus() {
let mut v = ~[]; let mut v = ~[];
let mut i = 0; let mut i = 0;
while i < 1500 { 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() { if r.gen() {
v.push_all_move(rv); v.push_all_move(rv);
} else { } else {
@ -104,12 +104,12 @@ fn vec_append() {
let mut v = ~[]; let mut v = ~[];
let mut i = 0; let mut i = 0;
while i < 1500 { 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() { if r.gen() {
v = vec::append(v, rv); v = slice::append(v, rv);
} }
else { else {
v = vec::append(rv, v); v = slice::append(rv, v);
} }
i += 1; i += 1;
} }
@ -120,7 +120,7 @@ fn vec_push_all() {
let mut v = ~[]; let mut v = ~[];
for i in range(0u, 1500) { 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() { if r.gen() {
v.push_all(rv); v.push_all(rv);
} }

View file

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
use std::os; use std::os;
use std::vec; use std::slice;
fn max(a: i32, b: i32) -> i32 { fn max(a: i32, b: i32) -> i32 {
if a > b { if a > b {
@ -20,9 +20,9 @@ fn max(a: i32, b: i32) -> i32 {
} }
fn fannkuch_redux(n: i32) -> i32 { fn fannkuch_redux(n: i32) -> i32 {
let mut perm = vec::from_elem(n as uint, 0i32); let mut perm = slice::from_elem(n as uint, 0i32);
let mut perm1 = vec::from_fn(n as uint, |i| i as i32); let mut perm1 = slice::from_fn(n as uint, |i| i as i32);
let mut count = vec::from_elem(n as uint, 0i32); let mut count = slice::from_elem(n as uint, 0i32);
let mut max_flips_count = 0i32; let mut max_flips_count = 0i32;
let mut perm_count = 0i32; let mut perm_count = 0i32;
let mut checksum = 0i32; let mut checksum = 0i32;

Some files were not shown because too many files have changed in this diff Show more