Fix fallout from Vec stabilization

This commit is contained in:
Alex Crichton 2014-09-17 12:56:31 -07:00
parent 087b9283a0
commit 0169218047
29 changed files with 141 additions and 156 deletions

View File

@ -273,8 +273,8 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
format!("--target={}", config.target), format!("--target={}", config.target),
"-L".to_string(), "-L".to_string(),
aux_dir.as_str().unwrap().to_string()); aux_dir.as_str().unwrap().to_string());
args.push_all_move(split_maybe_args(&config.target_rustcflags)); args.extend(split_maybe_args(&config.target_rustcflags).into_iter());
args.push_all_move(split_maybe_args(&props.compile_flags)); args.extend(split_maybe_args(&props.compile_flags).into_iter());
return ProcArgs { return ProcArgs {
prog: config.rustc_path.as_str().unwrap().to_string(), prog: config.rustc_path.as_str().unwrap().to_string(),
args: args, args: args,
@ -321,8 +321,8 @@ actual:\n\
config.build_base.as_str().unwrap().to_string(), config.build_base.as_str().unwrap().to_string(),
"-L".to_string(), "-L".to_string(),
aux_dir.as_str().unwrap().to_string()); aux_dir.as_str().unwrap().to_string());
args.push_all_move(split_maybe_args(&config.target_rustcflags)); args.extend(split_maybe_args(&config.target_rustcflags).into_iter());
args.push_all_move(split_maybe_args(&props.compile_flags)); args.extend(split_maybe_args(&props.compile_flags).into_iter());
// FIXME (#9639): This needs to handle non-utf8 paths // FIXME (#9639): This needs to handle non-utf8 paths
return ProcArgs { return ProcArgs {
prog: config.rustc_path.as_str().unwrap().to_string(), prog: config.rustc_path.as_str().unwrap().to_string(),
@ -1095,11 +1095,12 @@ fn compile_test_(config: &Config, props: &TestProps,
testfile: &Path, extra_args: &[String]) -> ProcRes { testfile: &Path, extra_args: &[String]) -> ProcRes {
let aux_dir = aux_output_dir_name(config, testfile); let aux_dir = aux_output_dir_name(config, testfile);
// FIXME (#9639): This needs to handle non-utf8 paths // FIXME (#9639): This needs to handle non-utf8 paths
let link_args = vec!("-L".to_string(), let mut link_args = vec!("-L".to_string(),
aux_dir.as_str().unwrap().to_string()); aux_dir.as_str().unwrap().to_string());
link_args.extend(extra_args.iter().map(|s| s.clone()));
let args = make_compile_args(config, let args = make_compile_args(config,
props, props,
link_args.append(extra_args), link_args,
|a, b| ThisFile(make_exe_name(a, b)), testfile); |a, b| ThisFile(make_exe_name(a, b)), testfile);
compose_and_run_compiler(config, props, testfile, args, None) compose_and_run_compiler(config, props, testfile, args, None)
} }
@ -1146,16 +1147,16 @@ fn compose_and_run_compiler(
for rel_ab in props.aux_builds.iter() { for rel_ab in props.aux_builds.iter() {
let abs_ab = config.aux_base.join(rel_ab.as_slice()); let abs_ab = config.aux_base.join(rel_ab.as_slice());
let aux_props = header::load_props(&abs_ab); let aux_props = header::load_props(&abs_ab);
let crate_type = if aux_props.no_prefer_dynamic { let mut crate_type = if aux_props.no_prefer_dynamic {
Vec::new() Vec::new()
} else { } else {
vec!("--crate-type=dylib".to_string()) vec!("--crate-type=dylib".to_string())
}; };
crate_type.extend(extra_link_args.clone().into_iter());
let aux_args = let aux_args =
make_compile_args(config, make_compile_args(config,
&aux_props, &aux_props,
crate_type.append( crate_type,
extra_link_args.as_slice()),
|a,b| { |a,b| {
let f = make_lib_name(a, b, testfile); let f = make_lib_name(a, b, testfile);
ThisDirectory(f.dir_path()) ThisDirectory(f.dir_path())
@ -1246,11 +1247,11 @@ fn make_compile_args(config: &Config,
}; };
args.push(path.as_str().unwrap().to_string()); args.push(path.as_str().unwrap().to_string());
if props.force_host { if props.force_host {
args.push_all_move(split_maybe_args(&config.host_rustcflags)); args.extend(split_maybe_args(&config.host_rustcflags).into_iter());
} else { } else {
args.push_all_move(split_maybe_args(&config.target_rustcflags)); args.extend(split_maybe_args(&config.target_rustcflags).into_iter());
} }
args.push_all_move(split_maybe_args(&props.compile_flags)); args.extend(split_maybe_args(&props.compile_flags).into_iter());
return ProcArgs { return ProcArgs {
prog: config.rustc_path.as_str().unwrap().to_string(), prog: config.rustc_path.as_str().unwrap().to_string(),
args: args, args: args,
@ -1267,10 +1268,9 @@ fn make_lib_name(config: &Config, auxfile: &Path, testfile: &Path) -> Path {
fn make_exe_name(config: &Config, testfile: &Path) -> Path { fn make_exe_name(config: &Config, testfile: &Path) -> Path {
let mut f = output_base_name(config, testfile); let mut f = output_base_name(config, testfile);
if !os::consts::EXE_SUFFIX.is_empty() { if !os::consts::EXE_SUFFIX.is_empty() {
match f.filename().map(|s| Vec::from_slice(s).append(os::consts::EXE_SUFFIX.as_bytes())) { let mut fname = f.filename().unwrap().to_vec();
Some(v) => f.set_filename(v), fname.extend(os::consts::EXE_SUFFIX.bytes());
None => () f.set_filename(fname);
}
} }
f f
} }
@ -1286,7 +1286,7 @@ fn make_run_args(config: &Config, props: &TestProps, testfile: &Path) ->
args.push(exe_file.as_str().unwrap().to_string()); args.push(exe_file.as_str().unwrap().to_string());
// Add the arguments in the run_flags directive // Add the arguments in the run_flags directive
args.push_all_move(split_maybe_args(&props.run_flags)); args.extend(split_maybe_args(&props.run_flags).into_iter());
let prog = args.remove(0).unwrap(); let prog = args.remove(0).unwrap();
return ProcArgs { return ProcArgs {
@ -1381,12 +1381,10 @@ fn make_out_name(config: &Config, testfile: &Path, extension: &str) -> Path {
} }
fn aux_output_dir_name(config: &Config, testfile: &Path) -> Path { fn aux_output_dir_name(config: &Config, testfile: &Path) -> Path {
let mut f = output_base_name(config, testfile); let f = output_base_name(config, testfile);
match f.filename().map(|s| Vec::from_slice(s).append(b".libaux")) { let mut fname = f.filename().unwrap().to_vec();
Some(v) => f.set_filename(v), fname.extend("libaux".bytes());
None => () f.with_filename(fname)
}
f
} }
fn output_testname(testfile: &Path) -> Path { fn output_testname(testfile: &Path) -> Path {
@ -1598,8 +1596,10 @@ fn append_suffix_to_stem(p: &Path, suffix: &str) -> Path {
if suffix.len() == 0 { if suffix.len() == 0 {
(*p).clone() (*p).clone()
} else { } else {
let stem = p.filestem().unwrap(); let mut stem = p.filestem().unwrap().to_vec();
p.with_filename(Vec::from_slice(stem).append(b"-").append(suffix.as_bytes())) stem.extend("-".bytes());
stem.extend(suffix.bytes());
p.with_filename(stem)
} }
} }
@ -1607,13 +1607,14 @@ fn compile_test_and_save_bitcode(config: &Config, props: &TestProps,
testfile: &Path) -> ProcRes { testfile: &Path) -> ProcRes {
let aux_dir = aux_output_dir_name(config, testfile); let aux_dir = aux_output_dir_name(config, testfile);
// FIXME (#9639): This needs to handle non-utf8 paths // FIXME (#9639): This needs to handle non-utf8 paths
let link_args = vec!("-L".to_string(), let mut link_args = vec!("-L".to_string(),
aux_dir.as_str().unwrap().to_string()); aux_dir.as_str().unwrap().to_string());
let llvm_args = vec!("--emit=bc,obj".to_string(), let llvm_args = vec!("--emit=bc,obj".to_string(),
"--crate-type=lib".to_string()); "--crate-type=lib".to_string());
link_args.extend(llvm_args.into_iter());
let args = make_compile_args(config, let args = make_compile_args(config,
props, props,
link_args.append(llvm_args.as_slice()), link_args,
|a, b| ThisDirectory(output_base_name(a, b).dir_path()), |a, b| ThisDirectory(output_base_name(a, b).dir_path()),
testfile); testfile);
compose_and_run_compiler(config, props, testfile, args, None) compose_and_run_compiler(config, props, testfile, args, None)

View File

@ -3833,8 +3833,9 @@ fn map<A: Clone, B: Clone>(f: |A| -> B, xs: &[A]) -> Vec<B> {
return vec![]; return vec![];
} }
let first: B = f(xs[0].clone()); let first: B = f(xs[0].clone());
let rest: Vec<B> = map(f, xs.slice(1, xs.len())); let mut rest: Vec<B> = map(f, xs.slice(1, xs.len()));
return vec![first].append(rest.as_slice()); rest.insert(0, first);
return rest;
} }
~~~~ ~~~~

View File

@ -631,7 +631,7 @@ impl Bitv {
let old_size = self.storage.len(); let old_size = self.storage.len();
let size = (size + uint::BITS - 1) / uint::BITS; let size = (size + uint::BITS - 1) / uint::BITS;
if old_size < size { if old_size < size {
self.storage.grow(size - old_size, &0); self.storage.grow(size - old_size, 0);
} }
} }
@ -687,7 +687,7 @@ impl Bitv {
// Allocate new words, if needed // Allocate new words, if needed
if new_nwords > self.storage.len() { if new_nwords > self.storage.len() {
let to_add = new_nwords - self.storage.len(); let to_add = new_nwords - self.storage.len();
self.storage.grow(to_add, &full_value); self.storage.grow(to_add, full_value);
} }
// Adjust internal bit count // Adjust internal bit count
self.nbits = new_nbits; self.nbits = new_nbits;

View File

@ -283,7 +283,11 @@ pub trait CloneableVector<T> {
impl<'a, T: Clone> CloneableVector<T> for &'a [T] { impl<'a, T: Clone> CloneableVector<T> for &'a [T] {
/// Returns a copy of `v`. /// Returns a copy of `v`.
#[inline] #[inline]
fn to_vec(&self) -> Vec<T> { Vec::from_slice(*self) } fn to_vec(&self) -> Vec<T> {
let mut vector = Vec::with_capacity(self.len());
vector.push_all(*self);
vector
}
#[inline(always)] #[inline(always)]
fn into_vec(self) -> Vec<T> { self.to_vec() } fn into_vec(self) -> Vec<T> { self.to_vec() }
@ -1039,7 +1043,7 @@ mod tests {
fn test_grow() { fn test_grow() {
// Test on-stack grow(). // Test on-stack grow().
let mut v = vec![]; let mut v = vec![];
v.grow(2u, &1i); v.grow(2u, 1i);
{ {
let v = v.as_slice(); let v = v.as_slice();
assert_eq!(v.len(), 2u); assert_eq!(v.len(), 2u);
@ -1048,7 +1052,7 @@ mod tests {
} }
// Test on-heap grow(). // Test on-heap grow().
v.grow(3u, &2i); v.grow(3u, 2i);
{ {
let v = v.as_slice(); let v = v.as_slice();
assert_eq!(v.len(), 5u); assert_eq!(v.len(), 5u);

View File

@ -67,6 +67,7 @@ use core::prelude::{range};
use {Deque, MutableSeq}; use {Deque, MutableSeq};
use hash; use hash;
use ringbuf::RingBuf; use ringbuf::RingBuf;
use slice::CloneableVector;
use string::String; use string::String;
use unicode; use unicode;
use vec::Vec; use vec::Vec;
@ -754,7 +755,7 @@ pub trait StrAllocating: Str {
#[inline] #[inline]
fn to_owned(&self) -> String { fn to_owned(&self) -> String {
unsafe { unsafe {
mem::transmute(Vec::from_slice(self.as_slice().as_bytes())) mem::transmute(self.as_slice().as_bytes().to_vec())
} }
} }

View File

@ -23,6 +23,7 @@ use core::raw::Slice as RawSlice;
use {Mutable, MutableSeq}; use {Mutable, MutableSeq};
use hash; use hash;
use slice::CloneableVector;
use str; use str;
use str::{CharRange, StrAllocating, MaybeOwned, Owned}; use str::{CharRange, StrAllocating, MaybeOwned, Owned};
use str::Slice as MaybeOwnedSlice; // So many `Slice`s... use str::Slice as MaybeOwnedSlice; // So many `Slice`s...
@ -75,9 +76,7 @@ impl String {
/// ``` /// ```
#[inline] #[inline]
pub fn from_str(string: &str) -> String { pub fn from_str(string: &str) -> String {
String { String { vec: string.as_bytes().to_vec() }
vec: Vec::from_slice(string.as_bytes())
}
} }
/// Deprecated. Replaced by `string::raw::from_parts` /// Deprecated. Replaced by `string::raw::from_parts`

View File

@ -273,16 +273,7 @@ impl<T> Vec<T> {
} }
impl<T: Clone> Vec<T> { impl<T: Clone> Vec<T> {
/// Iterates over the `second` vector, copying each element and appending it to /// Deprecated, call `extend` instead.
/// the `first`. Afterwards, the `first` is then returned for use again.
///
/// # Example
///
/// ```
/// let vec = vec![1i, 2i];
/// let vec = vec.append([3i, 4i]);
/// assert_eq!(vec, vec![1, 2, 3, 4]);
/// ```
#[inline] #[inline]
#[deprecated = "this function has been deprecated in favor of extend()"] #[deprecated = "this function has been deprecated in favor of extend()"]
pub fn append(mut self, second: &[T]) -> Vec<T> { pub fn append(mut self, second: &[T]) -> Vec<T> {
@ -290,21 +281,10 @@ impl<T: Clone> Vec<T> {
self self
} }
/// Constructs a `Vec` by cloning elements of a slice. /// Deprecated, call `to_vec()` instead
///
/// # Example
///
/// ```
/// let slice = [1i, 2, 3];
/// let vec = Vec::from_slice(slice);
/// ```
#[inline] #[inline]
#[deprecated = "this function has been deprecated in favor of to_vec()"] #[deprecated = "this function has been deprecated in favor of to_vec()"]
pub fn from_slice(values: &[T]) -> Vec<T> { pub fn from_slice(values: &[T]) -> Vec<T> { values.to_vec() }
let mut vector = Vec::new();
vector.push_all(values);
vector
}
/// Constructs a `Vec` with copies of a value. /// Constructs a `Vec` with copies of a value.
/// ///
@ -442,9 +422,7 @@ impl<T: Clone> Vec<T> {
#[unstable] #[unstable]
impl<T:Clone> Clone for Vec<T> { impl<T:Clone> Clone for Vec<T> {
fn clone(&self) -> Vec<T> { fn clone(&self) -> Vec<T> { self.as_slice().to_vec() }
Vec::from_slice(self.as_slice())
}
fn clone_from(&mut self, other: &Vec<T>) { fn clone_from(&mut self, other: &Vec<T>) {
// drop anything in self that will not be overwritten // drop anything in self that will not be overwritten
@ -736,16 +714,7 @@ impl<T> Vec<T> {
} }
} }
/// Appends one element to the vector provided. The vector itself is then /// Deprecated, call `push` instead
/// returned for use again.
///
/// # Example
///
/// ```
/// let vec = vec![1i, 2];
/// let vec = vec.append_one(3);
/// assert_eq!(vec, vec![1, 2, 3]);
/// ```
#[inline] #[inline]
#[deprecated = "call .push() instead"] #[deprecated = "call .push() instead"]
pub fn append_one(mut self, x: T) -> Vec<T> { pub fn append_one(mut self, x: T) -> Vec<T> {
@ -765,7 +734,7 @@ impl<T> Vec<T> {
/// vec.truncate(2); /// vec.truncate(2);
/// assert_eq!(vec, vec![1, 2]); /// assert_eq!(vec, vec![1, 2]);
/// ``` /// ```
#[stable] #[unstable = "waiting on failure semantics"]
pub fn truncate(&mut self, len: uint) { pub fn truncate(&mut self, len: uint) {
unsafe { unsafe {
// drop any extra elements // drop any extra elements
@ -1123,7 +1092,7 @@ impl<T> Vec<T> {
/// vec.insert(4, 5); /// vec.insert(4, 5);
/// assert_eq!(vec, vec![1, 4, 2, 3, 5]); /// assert_eq!(vec, vec![1, 4, 2, 3, 5]);
/// ``` /// ```
#[stable] #[unstable = "failure semantics need settling"]
pub fn insert(&mut self, index: uint, element: T) { pub fn insert(&mut self, index: uint, element: T) {
let len = self.len(); let len = self.len();
assert!(index <= len); assert!(index <= len);
@ -1160,7 +1129,7 @@ impl<T> Vec<T> {
/// // v is unchanged: /// // v is unchanged:
/// assert_eq!(v, vec![1, 3]); /// assert_eq!(v, vec![1, 3]);
/// ``` /// ```
#[stable] #[unstable = "failure semantics need settling"]
pub fn remove(&mut self, index: uint) -> Option<T> { pub fn remove(&mut self, index: uint) -> Option<T> {
let len = self.len(); let len = self.len();
if index < len { if index < len {
@ -1192,11 +1161,13 @@ impl<T> Vec<T> {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// # #![allow(deprecated)]
/// let mut vec = vec![box 1i]; /// let mut vec = vec![box 1i];
/// vec.push_all_move(vec![box 2, box 3, box 4]); /// vec.push_all_move(vec![box 2, box 3, box 4]);
/// assert_eq!(vec, vec![box 1, box 2, box 3, box 4]); /// assert_eq!(vec, vec![box 1, box 2, box 3, box 4]);
/// ``` /// ```
#[inline] #[inline]
#[deprecated = "use .extend(other.into_iter())"]
pub fn push_all_move(&mut self, other: Vec<T>) { pub fn push_all_move(&mut self, other: Vec<T>) {
self.extend(other.into_iter()); self.extend(other.into_iter());
} }

View File

@ -170,7 +170,7 @@ impl<'a,T:Clone> MaybeOwnedVector<'a,T> {
pub fn into_vec(self) -> Vec<T> { pub fn into_vec(self) -> Vec<T> {
match self { match self {
Growable(v) => v, Growable(v) => v,
Borrowed(v) => Vec::from_slice(v), Borrowed(v) => v.to_vec(),
} }
} }
} }

View File

@ -87,7 +87,7 @@ impl Writer for SeekableMemWriter {
// currently are // currently are
let difference = self.pos as i64 - self.buf.len() as i64; let difference = self.pos as i64 - self.buf.len() as i64;
if difference > 0 { if difference > 0 {
self.buf.grow(difference as uint, &0); self.buf.grow(difference as uint, 0);
} }
// Figure out what bytes will be used to overwrite what's currently // Figure out what bytes will be used to overwrite what's currently

View File

@ -156,7 +156,7 @@ impl<'r> Compiler<'r> {
Capture(cap, name, x) => { Capture(cap, name, x) => {
let len = self.names.len(); let len = self.names.len();
if cap >= len { if cap >= len {
self.names.grow(10 + cap - len, &None) self.names.grow(10 + cap - len, None)
} }
*self.names.get_mut(cap) = name; *self.names.get_mut(cap) = name;

View File

@ -986,9 +986,9 @@ fn combine_ranges(unordered: Vec<(char, char)>) -> Vec<(char, char)> {
// (or any of their negated forms). Note that this does not handle negation. // (or any of their negated forms). Note that this does not handle negation.
fn perl_unicode_class(which: char) -> Vec<(char, char)> { fn perl_unicode_class(which: char) -> Vec<(char, char)> {
match which.to_lowercase() { match which.to_lowercase() {
'd' => Vec::from_slice(PERLD), 'd' => PERLD.to_vec(),
's' => Vec::from_slice(PERLS), 's' => PERLS.to_vec(),
'w' => Vec::from_slice(PERLW), 'w' => PERLW.to_vec(),
_ => unreachable!(), _ => unreachable!(),
} }
} }
@ -997,7 +997,7 @@ fn perl_unicode_class(which: char) -> Vec<(char, char)> {
// `Cat` expression will never be a direct child of another `Cat` expression. // `Cat` expression will never be a direct child of another `Cat` expression.
fn concat_flatten(x: Ast, y: Ast) -> Ast { fn concat_flatten(x: Ast, y: Ast) -> Ast {
match (x, y) { match (x, y) {
(Cat(mut xs), Cat(ys)) => { xs.push_all_move(ys); Cat(xs) } (Cat(mut xs), Cat(ys)) => { xs.extend(ys.into_iter()); Cat(xs) }
(Cat(mut xs), ast) => { xs.push(ast); Cat(xs) } (Cat(mut xs), ast) => { xs.push(ast); Cat(xs) }
(ast, Cat(mut xs)) => { xs.insert(0, ast); Cat(xs) } (ast, Cat(mut xs)) => { xs.insert(0, ast); Cat(xs) }
(ast1, ast2) => Cat(vec!(ast1, ast2)), (ast1, ast2) => Cat(vec!(ast1, ast2)),
@ -1019,7 +1019,7 @@ fn is_valid_cap(c: char) -> bool {
fn find_class(classes: NamedClasses, name: &str) -> Option<Vec<(char, char)>> { fn find_class(classes: NamedClasses, name: &str) -> Option<Vec<(char, char)>> {
match classes.binary_search(|&(s, _)| s.cmp(&name)) { match classes.binary_search(|&(s, _)| s.cmp(&name)) {
slice::Found(i) => Some(Vec::from_slice(classes[i].val1())), slice::Found(i) => Some(classes[i].val1().to_vec()),
slice::NotFound(_) => None, slice::NotFound(_) => None,
} }
} }

View File

@ -133,7 +133,7 @@ impl<'a> NfaGen<'a> {
let init_groups = self.vec_expr(range(0, num_cap_locs), let init_groups = self.vec_expr(range(0, num_cap_locs),
|cx, _| cx.expr_none(self.sp)); |cx, _| cx.expr_none(self.sp));
let prefix_lit = Rc::new(Vec::from_slice(self.prog.prefix.as_slice().as_bytes())); let prefix_lit = Rc::new(self.prog.prefix.as_slice().as_bytes().to_vec());
let prefix_bytes = self.cx.expr_lit(self.sp, ast::LitBinary(prefix_lit)); let prefix_bytes = self.cx.expr_lit(self.sp, ast::LitBinary(prefix_lit));
let check_prefix = self.check_prefix(); let check_prefix = self.check_prefix();

View File

@ -505,7 +505,7 @@ fn external_path(cx: &DocContext, name: &str, substs: &subst::Substs) -> Path {
.iter() .iter()
.filter_map(|v| v.clean(cx)) .filter_map(|v| v.clean(cx))
.collect(); .collect();
let types = Vec::from_slice(substs.types.get_slice(subst::TypeSpace)); let types = substs.types.get_slice(subst::TypeSpace).to_vec();
let types = types.clean(cx); let types = types.clean(cx);
Path { Path {
global: false, global: false,
@ -661,8 +661,8 @@ impl<'a> Clean<Generics> for (&'a ty::Generics, subst::ParamSpace) {
fn clean(&self, cx: &DocContext) -> Generics { fn clean(&self, cx: &DocContext) -> Generics {
let (me, space) = *self; let (me, space) = *self;
Generics { Generics {
type_params: Vec::from_slice(me.types.get_slice(space)).clean(cx), type_params: me.types.get_slice(space).to_vec().clean(cx),
lifetimes: Vec::from_slice(me.regions.get_slice(space)).clean(cx), lifetimes: me.regions.get_slice(space).to_vec().clean(cx),
} }
} }
} }
@ -991,7 +991,7 @@ impl Clean<Item> for ty::Method {
self.fty.sig.clone()), self.fty.sig.clone()),
s => { s => {
let sig = ty::FnSig { let sig = ty::FnSig {
inputs: Vec::from_slice(self.fty.sig.inputs.slice_from(1)), inputs: self.fty.sig.inputs.slice_from(1).to_vec(),
..self.fty.sig.clone() ..self.fty.sig.clone()
}; };
let s = match s { let s = match s {

View File

@ -183,8 +183,8 @@ mod imp {
impl Lock { impl Lock {
pub fn new(p: &Path) -> Lock { pub fn new(p: &Path) -> Lock {
let p_16: Vec<u16> = p.as_str().unwrap().utf16_units().collect(); let mut p_16: Vec<u16> = p.as_str().unwrap().utf16_units().collect();
let p_16 = p_16.append_one(0); p_16.push(0);
let handle = unsafe { let handle = unsafe {
libc::CreateFileW(p_16.as_ptr(), libc::CreateFileW(p_16.as_ptr(),
libc::FILE_GENERIC_READ | libc::FILE_GENERIC_READ |

View File

@ -740,8 +740,9 @@ impl<'a> SourceCollector<'a> {
root_path.push_str("../"); root_path.push_str("../");
}); });
cur.push(Vec::from_slice(p.filename().expect("source has no filename")) let mut fname = p.filename().expect("source has no filename").to_vec();
.append(b".html")); fname.extend(".html".bytes());
cur.push(fname);
let mut w = BufferedWriter::new(try!(File::create(&cur))); let mut w = BufferedWriter::new(try!(File::create(&cur)));
let title = format!("{} -- source", cur.filename_display()); let title = format!("{} -- source", cur.filename_display());

View File

@ -47,6 +47,7 @@ mod imp {
use core::prelude::*; use core::prelude::*;
use alloc::boxed::Box; use alloc::boxed::Box;
use collections::slice::CloneableVector;
use collections::vec::Vec; use collections::vec::Vec;
use core::mem; use core::mem;
use core::slice; use core::slice;
@ -106,7 +107,7 @@ mod imp {
let mut len = 0; let mut len = 0;
while *base.offset(len) != 0 { len += 1; } while *base.offset(len) != 0 { len += 1; }
slice::raw::buf_as_slice(base, len as uint, |slice| { slice::raw::buf_as_slice(base, len as uint, |slice| {
Vec::from_slice(slice) slice.to_vec()
}) })
}) })
} }

View File

@ -655,7 +655,7 @@ impl rtio::RtioUdpSocket for UdpWatcher {
// see comments in StreamWatcher::write for why we may allocate a buffer // see comments in StreamWatcher::write for why we may allocate a buffer
// here. // here.
let data = if guard.can_timeout {Some(Vec::from_slice(buf))} else {None}; let data = if guard.can_timeout {Some(buf.to_vec())} else {None};
let uv_buf = if guard.can_timeout { let uv_buf = if guard.can_timeout {
slice_to_uv_buf(data.as_ref().unwrap().as_slice()) slice_to_uv_buf(data.as_ref().unwrap().as_slice())
} else { } else {

View File

@ -159,7 +159,7 @@ impl StreamWatcher {
// //
// To do this, the write context has an optionally owned vector of // To do this, the write context has an optionally owned vector of
// bytes. // bytes.
let data = if may_timeout {Some(Vec::from_slice(buf))} else {None}; let data = if may_timeout {Some(buf.to_vec())} else {None};
let uv_buf = if may_timeout { let uv_buf = if may_timeout {
slice_to_uv_buf(data.as_ref().unwrap().as_slice()) slice_to_uv_buf(data.as_ref().unwrap().as_slice())
} else { } else {

View File

@ -281,6 +281,7 @@ pub mod dl {
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
pub mod dl { pub mod dl {
use c_str::ToCStr; use c_str::ToCStr;
use collections::MutableSeq;
use iter::Iterator; use iter::Iterator;
use libc; use libc;
use os; use os;
@ -295,8 +296,8 @@ pub mod dl {
// Windows expects Unicode data // Windows expects Unicode data
let filename_cstr = filename.to_c_str(); let filename_cstr = filename.to_c_str();
let filename_str = str::from_utf8(filename_cstr.as_bytes_no_nul()).unwrap(); let filename_str = str::from_utf8(filename_cstr.as_bytes_no_nul()).unwrap();
let filename_str: Vec<u16> = filename_str.utf16_units().collect(); let mut filename_str: Vec<u16> = filename_str.utf16_units().collect();
let filename_str = filename_str.append_one(0); filename_str.push(0);
LoadLibraryW(filename_str.as_ptr() as *const libc::c_void) as *mut u8 LoadLibraryW(filename_str.as_ptr() as *const libc::c_void) as *mut u8
} }

View File

@ -15,7 +15,7 @@ use comm::{Sender, Receiver};
use io; use io;
use option::{None, Option, Some}; use option::{None, Option, Some};
use result::{Ok, Err}; use result::{Ok, Err};
use slice::{bytes, MutableSlice, ImmutableSlice}; use slice::{bytes, MutableSlice, ImmutableSlice, CloneableVector};
use str::StrSlice; use str::StrSlice;
use super::{Reader, Writer, IoResult}; use super::{Reader, Writer, IoResult};
use vec::Vec; use vec::Vec;
@ -118,7 +118,7 @@ impl Clone for ChanWriter {
impl Writer for ChanWriter { impl Writer for ChanWriter {
fn write(&mut self, buf: &[u8]) -> IoResult<()> { fn write(&mut self, buf: &[u8]) -> IoResult<()> {
self.tx.send_opt(Vec::from_slice(buf)).map_err(|_| { self.tx.send_opt(buf.to_vec()).map_err(|_| {
io::IoError { io::IoError {
kind: io::BrokenPipe, kind: io::BrokenPipe,
desc: "Pipe closed", desc: "Pipe closed",

View File

@ -61,7 +61,7 @@ use io::{IoResult, IoError, FileStat, SeekStyle, Seek, Writer, Reader};
use io::{Read, Truncate, SeekCur, SeekSet, ReadWrite, SeekEnd, Append}; use io::{Read, Truncate, SeekCur, SeekSet, ReadWrite, SeekEnd, Append};
use io::UpdateIoError; use io::UpdateIoError;
use io; use io;
use iter::Iterator; use iter::{Iterator, Extendable};
use kinds::Send; use kinds::Send;
use libc; use libc;
use option::{Some, None, Option}; use option::{Some, None, Option};
@ -688,7 +688,7 @@ impl Iterator<Path> for Directories {
e, path.display())); e, path.display()));
match result { match result {
Ok(dirs) => { self.stack.push_all_move(dirs); } Ok(dirs) => { self.stack.extend(dirs.into_iter()); }
Err(..) => {} Err(..) => {}
} }
} }

View File

@ -46,15 +46,14 @@ use ptr::RawPtr;
use ptr; use ptr;
use result::{Err, Ok, Result}; use result::{Err, Ok, Result};
use slice::{Slice, ImmutableSlice, MutableSlice, ImmutablePartialEqSlice}; use slice::{Slice, ImmutableSlice, MutableSlice, ImmutablePartialEqSlice};
use slice::CloneableVector;
use str::{Str, StrSlice, StrAllocating}; use str::{Str, StrSlice, StrAllocating};
use string::String; use string::String;
use sync::atomic::{AtomicInt, INIT_ATOMIC_INT, SeqCst}; use sync::atomic::{AtomicInt, INIT_ATOMIC_INT, SeqCst};
use vec::Vec; use vec::Vec;
#[cfg(unix)] #[cfg(unix)] use c_str::ToCStr;
use c_str::ToCStr; #[cfg(unix)] use libc::c_char;
#[cfg(unix)]
use libc::c_char;
/// Get the number of cores available /// Get the number of cores available
pub fn num_cpus() -> uint { pub fn num_cpus() -> uint {
@ -260,8 +259,11 @@ pub fn env_as_bytes() -> Vec<(Vec<u8>,Vec<u8>)> {
let mut i = 0; let mut i = 0;
while *ch.offset(i) != 0 { while *ch.offset(i) != 0 {
let p = &*ch.offset(i); let p = &*ch.offset(i);
let len = ptr::position(p, |c| *c == 0); let mut len = 0;
raw::buf_as_slice(p, len, |s| { while *(p as *const _).offset(len) != 0 {
len += 1;
}
raw::buf_as_slice(p, len as uint, |s| {
result.push(String::from_utf16_lossy(s).into_bytes()); result.push(String::from_utf16_lossy(s).into_bytes());
}); });
i += len as int + 1; i += len as int + 1;
@ -284,7 +286,7 @@ pub fn env_as_bytes() -> Vec<(Vec<u8>,Vec<u8>)> {
let mut result = Vec::new(); let mut result = Vec::new();
while *environ != 0 as *const _ { while *environ != 0 as *const _ {
let env_pair = let env_pair =
Vec::from_slice(CString::new(*environ, false).as_bytes_no_nul()); CString::new(*environ, false).as_bytes_no_nul().to_vec();
result.push(env_pair); result.push(env_pair);
environ = environ.offset(1); environ = environ.offset(1);
} }
@ -295,9 +297,9 @@ pub fn env_as_bytes() -> Vec<(Vec<u8>,Vec<u8>)> {
let mut pairs = Vec::new(); let mut pairs = Vec::new();
for p in input.iter() { for p in input.iter() {
let mut it = p.as_slice().splitn(1, |b| *b == b'='); let mut it = p.as_slice().splitn(1, |b| *b == b'=');
let key = Vec::from_slice(it.next().unwrap()); let key = it.next().unwrap().to_vec();
let default: &[u8] = &[]; let default: &[u8] = &[];
let val = Vec::from_slice(it.next().unwrap_or(default)); let val = it.next().unwrap_or(default).to_vec();
pairs.push((key, val)); pairs.push((key, val));
} }
pairs pairs
@ -351,8 +353,7 @@ pub fn getenv_as_bytes(n: &str) -> Option<Vec<u8>> {
if s.is_null() { if s.is_null() {
None None
} else { } else {
Some(Vec::from_slice(CString::new(s as *const i8, Some(CString::new(s as *const i8, false).as_bytes_no_nul().to_vec())
false).as_bytes_no_nul()))
} }
}) })
} }
@ -365,8 +366,8 @@ pub fn getenv(n: &str) -> Option<String> {
unsafe { unsafe {
with_env_lock(|| { with_env_lock(|| {
use os::windows::{fill_utf16_buf_and_decode}; use os::windows::{fill_utf16_buf_and_decode};
let n: Vec<u16> = n.utf16_units().collect(); let mut n: Vec<u16> = n.utf16_units().collect();
let n = n.append_one(0); n.push(0);
fill_utf16_buf_and_decode(|buf, sz| { fill_utf16_buf_and_decode(|buf, sz| {
libc::GetEnvironmentVariableW(n.as_ptr(), buf, sz) libc::GetEnvironmentVariableW(n.as_ptr(), buf, sz)
}) })
@ -412,10 +413,10 @@ pub fn setenv<T: BytesContainer>(n: &str, v: T) {
#[cfg(windows)] #[cfg(windows)]
fn _setenv(n: &str, v: &[u8]) { fn _setenv(n: &str, v: &[u8]) {
let n: Vec<u16> = n.utf16_units().collect(); let mut n: Vec<u16> = n.utf16_units().collect();
let n = n.append_one(0); n.push(0);
let v: Vec<u16> = ::str::from_utf8(v).unwrap().utf16_units().collect(); let mut v: Vec<u16> = ::str::from_utf8(v).unwrap().utf16_units().collect();
let v = v.append_one(0); v.push(0);
unsafe { unsafe {
with_env_lock(|| { with_env_lock(|| {
@ -442,8 +443,8 @@ pub fn unsetenv(n: &str) {
#[cfg(windows)] #[cfg(windows)]
fn _unsetenv(n: &str) { fn _unsetenv(n: &str) {
let n: Vec<u16> = n.utf16_units().collect(); let mut n: Vec<u16> = n.utf16_units().collect();
let n = n.append_one(0); n.push(0);
unsafe { unsafe {
with_env_lock(|| { with_env_lock(|| {
libc::SetEnvironmentVariableW(n.as_ptr(), ptr::null()); libc::SetEnvironmentVariableW(n.as_ptr(), ptr::null());
@ -883,7 +884,11 @@ pub fn change_dir(p: &Path) -> bool {
#[cfg(windows)] #[cfg(windows)]
fn chdir(p: &Path) -> bool { fn chdir(p: &Path) -> bool {
let p = match p.as_str() { let p = match p.as_str() {
Some(s) => s.utf16_units().collect::<Vec<u16>>().append_one(0), Some(s) => {
let mut p = s.utf16_units().collect::<Vec<u16>>();
p.push(0);
p
}
None => return false, None => return false,
}; };
unsafe { unsafe {
@ -1100,8 +1105,7 @@ unsafe fn load_argc_and_argv(argc: int,
use c_str::CString; use c_str::CString;
Vec::from_fn(argc as uint, |i| { Vec::from_fn(argc as uint, |i| {
Vec::from_slice(CString::new(*argv.offset(i as int), CString::new(*argv.offset(i as int), false).as_bytes_no_nul().to_vec()
false).as_bytes_no_nul())
}) })
} }
@ -1170,7 +1174,7 @@ fn real_args_as_bytes() -> Vec<Vec<u8>> {
mem::transmute(objc_msgSend(tmp, utf8Sel)); mem::transmute(objc_msgSend(tmp, utf8Sel));
let s = CString::new(utf_c_str, false); let s = CString::new(utf_c_str, false);
if s.is_not_null() { if s.is_not_null() {
res.push(Vec::from_slice(s.as_bytes_no_nul())) res.push(s.as_bytes_no_nul().to_vec())
} }
} }
} }

View File

@ -76,7 +76,7 @@ use option::{Option, None, Some};
use str; use str;
use str::{MaybeOwned, Str, StrSlice}; use str::{MaybeOwned, Str, StrSlice};
use string::String; use string::String;
use slice::Slice; use slice::{Slice, CloneableVector};
use slice::{ImmutablePartialEqSlice, ImmutableSlice}; use slice::{ImmutablePartialEqSlice, ImmutableSlice};
use vec::Vec; use vec::Vec;
@ -480,7 +480,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
let extlen = extension.container_as_bytes().len(); let extlen = extension.container_as_bytes().len();
match (name.rposition_elem(&dot), extlen) { match (name.rposition_elem(&dot), extlen) {
(None, 0) | (Some(0), 0) => None, (None, 0) | (Some(0), 0) => None,
(Some(idx), 0) => Some(Vec::from_slice(name.slice_to(idx))), (Some(idx), 0) => Some(name.slice_to(idx).to_vec()),
(idx, extlen) => { (idx, extlen) => {
let idx = match idx { let idx = match idx {
None | Some(0) => name.len(), None | Some(0) => name.len(),
@ -798,7 +798,7 @@ pub trait BytesContainer {
/// Consumes the receiver and converts it into Vec<u8> /// Consumes the receiver and converts it into Vec<u8>
#[inline] #[inline]
fn container_into_owned_bytes(self) -> Vec<u8> { fn container_into_owned_bytes(self) -> Vec<u8> {
Vec::from_slice(self.container_as_bytes()) self.container_as_bytes().to_vec()
} }
/// Returns the receiver interpreted as a utf-8 string, if possible /// Returns the receiver interpreted as a utf-8 string, if possible
#[inline] #[inline]

View File

@ -399,7 +399,7 @@ impl Path {
} }
}; };
match val { match val {
None => Vec::from_slice(v.as_slice()), None => v.as_slice().to_vec(),
Some(val) => val Some(val) => val
} }
} }

View File

@ -371,7 +371,7 @@ impl GenericPath for Path {
#[inline] #[inline]
fn into_vec(self) -> Vec<u8> { fn into_vec(self) -> Vec<u8> {
Vec::from_slice(self.repr.as_bytes()) self.repr.into_bytes()
} }
#[inline] #[inline]
@ -815,12 +815,14 @@ impl Path {
let mut s = String::with_capacity(n); let mut s = String::with_capacity(n);
match prefix { match prefix {
Some(DiskPrefix) => { Some(DiskPrefix) => {
s.push_char(prefix_.as_bytes()[0].to_ascii().to_uppercase().to_char()); s.push_char(prefix_.as_bytes()[0].to_ascii()
.to_uppercase().to_char());
s.push_char(':'); s.push_char(':');
} }
Some(VerbatimDiskPrefix) => { Some(VerbatimDiskPrefix) => {
s.push_str(prefix_.slice_to(4)); s.push_str(prefix_.slice_to(4));
s.push_char(prefix_.as_bytes()[4].to_ascii().to_uppercase().to_char()); s.push_char(prefix_.as_bytes()[4].to_ascii()
.to_uppercase().to_char());
s.push_str(prefix_.slice_from(5)); s.push_str(prefix_.slice_from(5));
} }
Some(UNCPrefix(a,b)) => { Some(UNCPrefix(a,b)) => {
@ -1619,7 +1621,7 @@ mod tests {
t!(s: "a\\b\\c", ["d".to_string(), "e".to_string()], "a\\b\\c\\d\\e"); t!(s: "a\\b\\c", ["d".to_string(), "e".to_string()], "a\\b\\c\\d\\e");
t!(v: b"a\\b\\c", [b"d", b"e"], b"a\\b\\c\\d\\e"); t!(v: b"a\\b\\c", [b"d", b"e"], b"a\\b\\c\\d\\e");
t!(v: b"a\\b\\c", [b"d", b"\\e", b"f"], b"\\e\\f"); t!(v: b"a\\b\\c", [b"d", b"\\e", b"f"], b"\\e\\f");
t!(v: b"a\\b\\c", [Vec::from_slice(b"d"), Vec::from_slice(b"e")], t!(v: b"a\\b\\c", [b"d".to_vec(), b"e".to_vec()],
b"a\\b\\c\\d\\e"); b"a\\b\\c\\d\\e");
} }
@ -1759,7 +1761,7 @@ mod tests {
t!(s: "a\\b\\c", ["d", "\\e", "f"], "\\e\\f"); t!(s: "a\\b\\c", ["d", "\\e", "f"], "\\e\\f");
t!(s: "a\\b\\c", ["d".to_string(), "e".to_string()], "a\\b\\c\\d\\e"); t!(s: "a\\b\\c", ["d".to_string(), "e".to_string()], "a\\b\\c\\d\\e");
t!(v: b"a\\b\\c", [b"d", b"e"], b"a\\b\\c\\d\\e"); t!(v: b"a\\b\\c", [b"d", b"e"], b"a\\b\\c\\d\\e");
t!(v: b"a\\b\\c", [Vec::from_slice(b"d"), Vec::from_slice(b"e")], t!(v: b"a\\b\\c", [b"d".to_vec(), b"e".to_vec()],
b"a\\b\\c\\d\\e"); b"a\\b\\c\\d\\e");
} }

View File

@ -505,8 +505,8 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<Vec<u8> ,String> {
if flags.precision > s.len() { if flags.precision > s.len() {
let mut s_ = Vec::with_capacity(flags.precision); let mut s_ = Vec::with_capacity(flags.precision);
let n = flags.precision - s.len(); let n = flags.precision - s.len();
s_.grow(n, &b'0'); s_.grow(n, b'0');
s_.push_all_move(s); s_.extend(s.into_iter());
s = s_; s = s_;
} }
assert!(!s.is_empty(), "string conversion produced empty result"); assert!(!s.is_empty(), "string conversion produced empty result");
@ -524,7 +524,7 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<Vec<u8> ,String> {
FormatHex => { FormatHex => {
if flags.alternate { if flags.alternate {
let s_ = replace(&mut s, vec!(b'0', b'x')); let s_ = replace(&mut s, vec!(b'0', b'x'));
s.push_all_move(s_); s.extend(s_.into_iter());
} }
} }
FormatHEX => { FormatHEX => {
@ -536,7 +536,7 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<Vec<u8> ,String> {
.collect(); .collect();
if flags.alternate { if flags.alternate {
let s_ = replace(&mut s, vec!(b'0', b'X')); let s_ = replace(&mut s, vec!(b'0', b'X'));
s.push_all_move(s_); s.extend(s_.into_iter());
} }
} }
FormatString => unreachable!() FormatString => unreachable!()
@ -546,7 +546,7 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<Vec<u8> ,String> {
Words(s) => { Words(s) => {
match op { match op {
FormatString => { FormatString => {
let mut s = Vec::from_slice(s.as_bytes()); let mut s = s.as_bytes().to_vec();
if flags.precision > 0 && flags.precision < s.len() { if flags.precision > 0 && flags.precision < s.len() {
s.truncate(flags.precision); s.truncate(flags.precision);
} }
@ -562,11 +562,11 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<Vec<u8> ,String> {
if flags.width > s.len() { if flags.width > s.len() {
let n = flags.width - s.len(); let n = flags.width - s.len();
if flags.left { if flags.left {
s.grow(n, &b' '); s.grow(n, b' ');
} else { } else {
let mut s_ = Vec::with_capacity(flags.width); let mut s_ = Vec::with_capacity(flags.width);
s_.grow(n, &b' '); s_.grow(n, b' ');
s_.push_all_move(s); s_.extend(s.into_iter());
s = s_; s = s_;
} }
} }

View File

@ -290,9 +290,8 @@ pub fn parse(file: &mut io::Reader, longnames: bool)
match nulpos { match nulpos {
Some(len) => { Some(len) => {
string_map.insert(name.to_string(), string_map.insert(name.to_string(),
Vec::from_slice( string_table.slice(offset as uint,
string_table.slice(offset as uint, offset as uint + len).to_vec())
offset as uint + len)))
}, },
None => { None => {
return Err("invalid file: missing NUL in \ return Err("invalid file: missing NUL in \
@ -314,10 +313,10 @@ pub fn parse(file: &mut io::Reader, longnames: bool)
/// Create a dummy TermInfo struct for msys terminals /// Create a dummy TermInfo struct for msys terminals
pub fn msys_terminfo() -> Box<TermInfo> { pub fn msys_terminfo() -> Box<TermInfo> {
let mut strings = HashMap::new(); let mut strings = HashMap::new();
strings.insert("sgr0".to_string(), Vec::from_slice(b"\x1B[0m")); strings.insert("sgr0".to_string(), b"\x1B[0m".to_vec());
strings.insert("bold".to_string(), Vec::from_slice(b"\x1B[1m")); strings.insert("bold".to_string(), b"\x1B[1m".to_vec());
strings.insert("setaf".to_string(), Vec::from_slice(b"\x1B[3%p1%dm")); strings.insert("setaf".to_string(), b"\x1B[3%p1%dm".to_vec());
strings.insert("setab".to_string(), Vec::from_slice(b"\x1B[4%p1%dm")); strings.insert("setab".to_string(), b"\x1B[4%p1%dm".to_vec());
box TermInfo { box TermInfo {
names: vec!("cygwin".to_string()), // msys is a fork of an older cygwin version names: vec!("cygwin".to_string()), // msys is a fork of an older cygwin version
bools: HashMap::new(), bools: HashMap::new(),

View File

@ -261,13 +261,13 @@ impl<'a, T: FloatMath + FromPrimitive> Stats<T> for &'a [T] {
} }
fn percentile(self, pct: T) -> T { fn percentile(self, pct: T) -> T {
let mut tmp = Vec::from_slice(self); let mut tmp = self.to_vec();
local_sort(tmp.as_mut_slice()); local_sort(tmp.as_mut_slice());
percentile_of_sorted(tmp.as_slice(), pct) percentile_of_sorted(tmp.as_slice(), pct)
} }
fn quartiles(self) -> (T,T,T) { fn quartiles(self) -> (T,T,T) {
let mut tmp = Vec::from_slice(self); let mut tmp = self.to_vec();
local_sort(tmp.as_mut_slice()); local_sort(tmp.as_mut_slice());
let first = FromPrimitive::from_uint(25).unwrap(); let first = FromPrimitive::from_uint(25).unwrap();
let a = percentile_of_sorted(tmp.as_slice(), first); let a = percentile_of_sorted(tmp.as_slice(), first);
@ -318,7 +318,7 @@ fn percentile_of_sorted<T: Float + FromPrimitive>(sorted_samples: &[T],
/// ///
/// See: http://en.wikipedia.org/wiki/Winsorising /// See: http://en.wikipedia.org/wiki/Winsorising
pub fn winsorize<T: Float + FromPrimitive>(samples: &mut [T], pct: T) { pub fn winsorize<T: Float + FromPrimitive>(samples: &mut [T], pct: T) {
let mut tmp = Vec::from_slice(samples); let mut tmp = samples.to_vec();
local_sort(tmp.as_mut_slice()); local_sort(tmp.as_mut_slice());
let lo = percentile_of_sorted(tmp.as_slice(), pct); let lo = percentile_of_sorted(tmp.as_slice(), pct);
let hundred: T = FromPrimitive::from_uint(100).unwrap(); let hundred: T = FromPrimitive::from_uint(100).unwrap();

View File

@ -12,7 +12,7 @@ fn main() {
let mut vector = vec![1u, 2]; let mut vector = vec![1u, 2];
for &x in vector.iter() { for &x in vector.iter() {
let cap = vector.capacity(); let cap = vector.capacity();
vector.grow(cap, &0u); //~ ERROR cannot borrow vector.grow(cap, 0u); //~ ERROR cannot borrow
*vector.get_mut(1u) = 5u; //~ ERROR cannot borrow *vector.get_mut(1u) = 5u; //~ ERROR cannot borrow
} }
} }