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

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
internal details.
Wrapping the functions which expect buffers involves using the `vec::raw` module to manipulate Rust
Wrapping the functions which expect buffers involves using the `slice::raw` module to manipulate Rust
vectors as pointers to memory. Rust's vectors are guaranteed to be a contiguous block of memory. The
length is number of elements currently contained, and the capacity is the total size in elements of
the allocated memory. The length is less than or equal to the capacity.
@ -103,7 +103,7 @@ pub fn compress(src: &[u8]) -> ~[u8] {
let psrc = src.as_ptr();
let mut dstlen = snappy_max_compressed_length(srclen);
let mut dst = vec::with_capacity(dstlen as uint);
let mut dst = slice::with_capacity(dstlen as uint);
let pdst = dst.as_mut_ptr();
snappy_compress(psrc, srclen, pdst, &mut dstlen);
@ -125,7 +125,7 @@ pub fn uncompress(src: &[u8]) -> Option<~[u8]> {
let mut dstlen: size_t = 0;
snappy_uncompressed_length(psrc, srclen, &mut dstlen);
let mut dst = vec::with_capacity(dstlen as uint);
let mut dst = slice::with_capacity(dstlen as uint);
let pdst = dst.as_mut_ptr();
if snappy_uncompress(psrc, srclen, pdst, &mut dstlen) == 0 {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -18,7 +18,7 @@ use std::libc::{c_int, c_void};
use std::libc;
use std::mem;
use std::rt::rtio;
use std::vec;
use std::slice;
use std::vec_ng::Vec;
use io::{IoResult, retry, keep_going};
@ -417,7 +417,7 @@ pub fn readlink(p: &CString) -> IoResult<Path> {
if len == -1 {
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 {
libc::readlink(p, buf.as_ptr() as *mut libc::c_char,
len as libc::size_t) as libc::c_int

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -30,7 +30,7 @@ use std::cmp;
use std::io;
use std::os::consts::{macos, freebsd, linux, android, win32};
use std::str;
use std::vec;
use std::slice;
use std::vec_ng::Vec;
use collections::{HashMap, HashSet};
@ -443,7 +443,7 @@ fn get_metadata_section_imp(os: Os, filename: &Path) -> Result<MetadataBlob, ~st
debug!("checking {} bytes of metadata-version stamp",
vlen);
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);
if !version_ok { return Err(format!("incompatible metadata version found: '{}'",
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);
debug!("inflating {} bytes of compressed metadata",
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);
found = Ok(MetadataVec(inflated));
});

View File

@ -19,7 +19,7 @@
use std::io;
use std::uint;
use std::vec;
use std::slice;
use std::vec_ng::Vec;
use syntax::ast;
use syntax::ast_util;
@ -332,7 +332,7 @@ impl<'a, O:DataFlowOperator+Clone+'static> DataFlowContext<'a, O> {
changed: true
};
let mut temp = vec::from_elem(self.words_per_id, 0u);
let mut temp = slice::from_elem(self.words_per_id, 0u);
let mut loop_scopes = Vec::new();
while propcx.changed {

View File

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

View File

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

View File

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

View File

@ -148,7 +148,7 @@ use collections::HashSet;
use std::libc::{c_uint, c_ulonglong, c_longlong};
use std::ptr;
use std::sync::atomics;
use std::vec;
use std::slice;
use std::vec_ng::Vec;
use syntax::codemap::{Span, Pos};
use syntax::{abi, ast, codemap, ast_util, ast_map, opt_vec};
@ -709,7 +709,7 @@ pub fn create_function_debug_context(cx: &CrateContext,
return create_DIArray(DIB(cx), []);
}
let mut signature = vec::with_capacity(fn_decl.inputs.len() + 1);
let mut signature = slice::with_capacity(fn_decl.inputs.len() + 1);
// Return type -- llvm::DIBuilder wants this at index 0
match fn_decl.output.node {

View File

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

View File

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

View File

@ -118,7 +118,7 @@ use std::cell::{Cell, RefCell};
use collections::HashMap;
use std::mem::replace;
use std::result;
use std::vec;
use std::slice;
use std::vec_ng::Vec;
use std::vec_ng;
use syntax::abi::AbiSet;
@ -3978,7 +3978,7 @@ pub fn check_bounds_are_used(ccx: &CrateCtxt,
// make a vector of booleans initially false, set to true when used
if tps.len() == 0u { return; }
let mut tps_used = vec::from_elem(tps.len(), false);
let mut tps_used = slice::from_elem(tps.len(), false);
ty::walk_ty(ty, |t| {
match ty::get(t).sty {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -40,7 +40,7 @@ use rt::local::Local;
use rt::rtio::{DontClose, IoFactory, LocalIo, RtioFileStream, RtioTTY};
use rt::task::Task;
use str::StrSlice;
use vec::ImmutableVector;
use slice::ImmutableVector;
// And so begins the tale of acquiring a uv handle to a stdio stream on all
// platforms in all situations. Our story begins by splitting the world into two

View File

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

View File

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

View File

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

View File

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

View File

@ -1727,12 +1727,12 @@ mod bench {
extern crate test;
use self::test::BenchHarness;
use num;
use vec;
use slice;
use prelude::*;
#[bench]
fn bench_pow_function(b: &mut BenchHarness) {
let v = vec::from_fn(1024, |n| n);
let v = slice::from_fn(1024, |n| n);
b.iter(|| {v.iter().fold(0, |old, new| num::pow(old, *new));});
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -16,7 +16,7 @@ use rt::rtio::EventLoop;
#[cfg(stage0)] use cmp::TotalOrd;
#[cfg(stage0)] use container::MutableSet;
#[cfg(stage0)] use iter::Iterator;
#[cfg(stage0)] use vec::{ImmutableVector, OwnedVector};
#[cfg(stage0)] use slice::{ImmutableVector, OwnedVector};
// Need to tell the linker on OS X to not barf on undefined symbols
// and instead look them up at runtime, which we need to resolve

View File

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

View File

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

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

View File

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

View File

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

View File

@ -61,7 +61,7 @@ use ptr::RawPtr;
use sync::arc::UnsafeArc;
use sync::atomics::{AtomicInt, AtomicPtr, SeqCst};
use unstable::sync::Exclusive;
use vec::{OwnedVector, ImmutableVector};
use slice::{OwnedVector, ImmutableVector};
// Once the queue is less than 1/K full, then it will be downsized. Note that
// the deque requires that this number be less than 2.
@ -404,7 +404,7 @@ mod tests {
use rand::Rng;
use sync::atomics::{AtomicBool, INIT_ATOMIC_BOOL, SeqCst,
AtomicUint, INIT_ATOMIC_UINT};
use vec;
use slice;
#[test]
fn smoke() {
@ -600,7 +600,7 @@ mod tests {
let mut pool = BufferPool::<(int, uint)>::new();
let (mut w, s) = pool.deque();
let (threads, hits) = vec::unzip(range(0, NTHREADS).map(|_| {
let (threads, hits) = slice::unzip(range(0, NTHREADS).map(|_| {
let s = s.clone();
let unique_box = ~AtomicUint::new(0);
let thread_box = unsafe {

View File

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

View File

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

View File

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

View File

@ -21,11 +21,11 @@
* extern crate sync;
* extern crate rand;
*
* use std::vec;
* use std::slice;
* use sync::Arc;
*
* fn main() {
* let numbers = vec::from_fn(100, |i| (i as f32) * rand::random());
* let numbers = slice::from_fn(100, |i| (i as f32) * rand::random());
* let shared_numbers = Arc::new(numbers);
*
* for _ in range(0, 10) {

View File

@ -13,9 +13,8 @@
/// A task pool abstraction. Useful for achieving predictable CPU
/// parallelism.
use std::task;
use std::vec;
use std::slice;
enum Msg<T> {
Execute(proc(&T)),
@ -47,7 +46,7 @@ impl<T> TaskPool<T> {
-> TaskPool<T> {
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 init_fn = init_fn_factory();

View File

@ -520,7 +520,7 @@ pub enum Expr_ {
ExprIndex(@Expr, @Expr),
/// 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.
ExprPath(Path),

View File

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

View File

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

View File

@ -16,7 +16,7 @@
*/
use std::default::Default;
use std::vec;
use std::slice;
use std::vec_ng::Vec;
#[deriving(Clone, Encodable, Decodable, Hash)]
@ -176,7 +176,7 @@ impl<T> Default for OptVec<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> {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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