renamed vec::from_slice to vec::to_owned
This commit is contained in:
parent
ad8e236f32
commit
b7da975049
21 changed files with 39 additions and 39 deletions
|
@ -568,7 +568,7 @@ impl<R: Rng> RngUtil for R {
|
|||
|
||||
/// Shuffle a vec
|
||||
fn shuffle<T:Copy>(&mut self, values: &[T]) -> ~[T] {
|
||||
let mut m = vec::from_slice(values);
|
||||
let mut m = vec::to_owned(values);
|
||||
self.shuffle_mut(m);
|
||||
m
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ pub fn from_elem<T:Copy>(n_elts: uint, t: T) -> ~[T] {
|
|||
}
|
||||
|
||||
/// Creates a new unique vector with the same contents as the slice
|
||||
pub fn from_slice<T:Copy>(t: &[T]) -> ~[T] {
|
||||
pub fn to_owned<T:Copy>(t: &[T]) -> ~[T] {
|
||||
from_fn(t.len(), |i| t[i])
|
||||
}
|
||||
|
||||
|
@ -3451,19 +3451,19 @@ mod tests {
|
|||
let mut results: ~[~[int]];
|
||||
|
||||
results = ~[];
|
||||
for each_permutation(~[]) |v| { results.push(from_slice(v)); }
|
||||
for each_permutation(~[]) |v| { results.push(to_owned(v)); }
|
||||
assert!(results == ~[~[]]);
|
||||
|
||||
results = ~[];
|
||||
for each_permutation(~[7]) |v| { results.push(from_slice(v)); }
|
||||
for each_permutation(~[7]) |v| { results.push(to_owned(v)); }
|
||||
assert!(results == ~[~[7]]);
|
||||
|
||||
results = ~[];
|
||||
for each_permutation(~[1,1]) |v| { results.push(from_slice(v)); }
|
||||
for each_permutation(~[1,1]) |v| { results.push(to_owned(v)); }
|
||||
assert!(results == ~[~[1,1],~[1,1]]);
|
||||
|
||||
results = ~[];
|
||||
for each_permutation(~[5,2,0]) |v| { results.push(from_slice(v)); }
|
||||
for each_permutation(~[5,2,0]) |v| { results.push(to_owned(v)); }
|
||||
assert!(results ==
|
||||
~[~[5,2,0],~[5,0,2],~[2,5,0],~[2,0,5],~[0,5,2],~[0,2,5]]);
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ fn do_command(command: &Command, args: &[~str]) -> ValidUsage {
|
|||
let (prog, prog_args) = (words.head(), words.tail());
|
||||
let exitstatus = run::run_program(
|
||||
*prog,
|
||||
vec::append(vec::from_slice(prog_args), args)
|
||||
vec::append(vec::to_owned(prog_args), args)
|
||||
);
|
||||
os::set_exit_status(exitstatus);
|
||||
Valid
|
||||
|
|
|
@ -580,7 +580,7 @@ pub fn maybe_get_item_ast(intr: @ident_interner, cdata: cmd, tcx: ty::ctxt,
|
|||
let item_doc = lookup_item(id, cdata.data);
|
||||
let path = {
|
||||
let item_path = item_path(intr, item_doc);
|
||||
vec::from_slice(item_path.init())
|
||||
vec::to_owned(item_path.init())
|
||||
};
|
||||
match decode_inlined_item(cdata, tcx, copy path, item_doc) {
|
||||
Some(ref ii) => csearch::found((/*bad*/copy *ii)),
|
||||
|
|
|
@ -1420,7 +1420,7 @@ pub fn encode_metadata(parms: EncodeParams, crate: &crate) -> ~[u8] {
|
|||
//
|
||||
// Should be:
|
||||
//
|
||||
// vec::from_slice(metadata_encoding_version) +
|
||||
// vec::to_owned(metadata_encoding_version) +
|
||||
|
||||
let writer_bytes: &mut ~[u8] = wr.bytes;
|
||||
|
||||
|
|
|
@ -488,7 +488,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
|
|||
match cx.tcx.def_map.find(&pat_id) {
|
||||
Some(&def_variant(_, id)) => {
|
||||
if variant(id) == *ctor_id {
|
||||
Some(vec::from_slice(r.tail()))
|
||||
Some(vec::to_owned(r.tail()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -507,7 +507,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
|
|||
_ => fail!(~"type error")
|
||||
};
|
||||
if match_ {
|
||||
Some(vec::from_slice(r.tail()))
|
||||
Some(vec::to_owned(r.tail()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -538,7 +538,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
|
|||
_ => fail!(~"type error")
|
||||
};
|
||||
if match_ {
|
||||
Some(vec::from_slice(r.tail()))
|
||||
Some(vec::to_owned(r.tail()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -548,7 +548,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
|
|||
Some(args) => args,
|
||||
None => vec::from_elem(arity, wild())
|
||||
};
|
||||
Some(vec::append(args, vec::from_slice(r.tail())))
|
||||
Some(vec::append(args, vec::to_owned(r.tail())))
|
||||
}
|
||||
def_variant(_, _) => None,
|
||||
|
||||
|
@ -560,7 +560,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
|
|||
Some(args) => new_args = args,
|
||||
None => new_args = vec::from_elem(arity, wild())
|
||||
}
|
||||
Some(vec::append(new_args, vec::from_slice(r.tail())))
|
||||
Some(vec::append(new_args, vec::to_owned(r.tail())))
|
||||
}
|
||||
_ => None
|
||||
}
|
||||
|
@ -578,7 +578,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
|
|||
_ => wild()
|
||||
}
|
||||
});
|
||||
Some(vec::append(args, vec::from_slice(r.tail())))
|
||||
Some(vec::append(args, vec::to_owned(r.tail())))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -608,7 +608,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
|
|||
_ => wild()
|
||||
}
|
||||
});
|
||||
Some(vec::append(args, vec::from_slice(r.tail())))
|
||||
Some(vec::append(args, vec::to_owned(r.tail())))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -627,21 +627,21 @@ pub fn specialize(cx: @MatchCheckCtxt,
|
|||
single => true,
|
||||
_ => fail!(~"type error")
|
||||
};
|
||||
if match_ { Some(vec::from_slice(r.tail())) } else { None }
|
||||
if match_ { Some(vec::to_owned(r.tail())) } else { None }
|
||||
}
|
||||
pat_range(lo, hi) => {
|
||||
let (c_lo, c_hi) = match *ctor_id {
|
||||
val(ref v) => ((/*bad*/copy *v), (/*bad*/copy *v)),
|
||||
range(ref lo, ref hi) =>
|
||||
((/*bad*/copy *lo), (/*bad*/copy *hi)),
|
||||
single => return Some(vec::from_slice(r.tail())),
|
||||
single => return Some(vec::to_owned(r.tail())),
|
||||
_ => fail!(~"type error")
|
||||
};
|
||||
let v_lo = eval_const_expr(cx.tcx, lo),
|
||||
v_hi = eval_const_expr(cx.tcx, hi);
|
||||
let match_ = compare_const_vals(&c_lo, &v_lo) >= 0 &&
|
||||
compare_const_vals(&c_hi, &v_hi) <= 0;
|
||||
if match_ { Some(vec::from_slice(r.tail())) } else { None }
|
||||
if match_ { Some(vec::to_owned(r.tail())) } else { None }
|
||||
}
|
||||
pat_vec(before, slice, after) => {
|
||||
match *ctor_id {
|
||||
|
@ -674,7 +674,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
|
|||
}
|
||||
|
||||
pub fn default(cx: @MatchCheckCtxt, r: &[@pat]) -> Option<~[@pat]> {
|
||||
if is_wild(cx, r[0]) { Some(vec::from_slice(r.tail())) }
|
||||
if is_wild(cx, r[0]) { Some(vec::to_owned(r.tail())) }
|
||||
else { None }
|
||||
}
|
||||
|
||||
|
|
|
@ -217,7 +217,7 @@ fn mk_struct(cx: @CrateContext, tys: &[ty::t], packed: bool) -> Struct {
|
|||
size: machine::llsize_of_alloc(cx, llty_rec) /*bad*/as u64,
|
||||
align: machine::llalign_of_min(cx, llty_rec) /*bad*/as u64,
|
||||
packed: packed,
|
||||
fields: vec::from_slice(tys)
|
||||
fields: vec::to_owned(tys)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,8 +71,8 @@ pub impl FnType {
|
|||
let llretptr = GEPi(bcx, llargbundle, [0u, n]);
|
||||
let llretloc = Load(bcx, llretptr);
|
||||
llargvals = ~[llretloc];
|
||||
atys = vec::from_slice(atys.tail());
|
||||
attrs = vec::from_slice(attrs.tail());
|
||||
atys = vec::to_owned(atys.tail());
|
||||
attrs = vec::to_owned(attrs.tail());
|
||||
}
|
||||
|
||||
while i < n {
|
||||
|
@ -137,8 +137,8 @@ pub impl FnType {
|
|||
let mut attrs = /*bad*/copy self.attrs;
|
||||
let mut j = 0u;
|
||||
let llretptr = if self.sret {
|
||||
atys = vec::from_slice(atys.tail());
|
||||
attrs = vec::from_slice(attrs.tail());
|
||||
atys = vec::to_owned(atys.tail());
|
||||
attrs = vec::to_owned(attrs.tail());
|
||||
j = 1u;
|
||||
get_param(llwrapfn, 0u)
|
||||
} else if self.ret_ty.cast {
|
||||
|
|
|
@ -3813,7 +3813,7 @@ pub fn item_path(cx: ctxt, id: ast::def_id) -> ast_map::path {
|
|||
}
|
||||
|
||||
ast_map::node_variant(ref variant, _, path) => {
|
||||
vec::append_one(vec::from_slice(vec::init(*path)),
|
||||
vec::append_one(vec::to_owned(vec::init(*path)),
|
||||
ast_map::path_name((*variant).node.name))
|
||||
}
|
||||
|
||||
|
|
|
@ -442,7 +442,7 @@ pub mod flatteners {
|
|||
T: Decodable<D>>(
|
||||
buf: &[u8])
|
||||
-> T {
|
||||
let buf = vec::from_slice(buf);
|
||||
let buf = vec::to_owned(buf);
|
||||
let buf_reader = @BufReader::new(buf);
|
||||
let reader = buf_reader as @Reader;
|
||||
let mut deser: D = FromReader::from_reader(reader);
|
||||
|
|
|
@ -339,7 +339,7 @@ pub fn getopts(args: &[~str], opts: &[Opt]) -> Result {
|
|||
}
|
||||
i += 1;
|
||||
}
|
||||
return Ok(Matches {opts: vec::from_slice(opts),
|
||||
return Ok(Matches {opts: vec::to_owned(opts),
|
||||
vals: vals,
|
||||
free: free});
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ pub fn md4(msg: &[u8]) -> Quad {
|
|||
let orig_len: u64 = (vec::len(msg) * 8u) as u64;
|
||||
|
||||
// pad message
|
||||
let mut msg = vec::append(vec::from_slice(msg), ~[0x80u8]);
|
||||
let mut msg = vec::append(vec::to_owned(msg), ~[0x80u8]);
|
||||
let mut bitlen = orig_len + 8u64;
|
||||
while (bitlen + 64u64) % 512u64 > 0u64 {
|
||||
msg.push(0u8);
|
||||
|
|
|
@ -541,7 +541,7 @@ impl BigUint {
|
|||
/// Creates and initializes an BigUint.
|
||||
#[inline(always)]
|
||||
pub fn from_slice(slice: &[BigDigit]) -> BigUint {
|
||||
return BigUint::new(vec::from_slice(slice));
|
||||
return BigUint::new(vec::to_owned(slice));
|
||||
}
|
||||
|
||||
/// Creates and initializes an BigUint.
|
||||
|
|
|
@ -52,7 +52,7 @@ impl<'self> Stats for &'self [f64] {
|
|||
|
||||
fn median(self) -> f64 {
|
||||
assert!(self.len() != 0);
|
||||
let mut tmp = vec::from_slice(self);
|
||||
let mut tmp = vec::to_owned(self);
|
||||
sort::tim_sort(tmp);
|
||||
if tmp.len() & 1 == 0 {
|
||||
let m = tmp.len() / 2;
|
||||
|
|
|
@ -255,7 +255,7 @@ pub fn last_meta_item_list_by_name(items: ~[@ast::meta_item], name: &str)
|
|||
|
||||
pub fn sort_meta_items(items: &[@ast::meta_item]) -> ~[@ast::meta_item] {
|
||||
// This is sort of stupid here, converting to a vec of mutables and back
|
||||
let mut v = vec::from_slice(items);
|
||||
let mut v = vec::to_owned(items);
|
||||
do std::sort::quick_sort(v) |ma, mb| {
|
||||
get_meta_item_name(*ma) <= get_meta_item_name(*mb)
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ pub fn expand_asm(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
|
|||
-> base::MacResult {
|
||||
let p = parse::new_parser_from_tts(cx.parse_sess(),
|
||||
cx.cfg(),
|
||||
vec::from_slice(tts));
|
||||
vec::to_owned(tts));
|
||||
|
||||
let mut asm = ~"";
|
||||
let mut outputs = ~[];
|
||||
|
|
|
@ -386,7 +386,7 @@ pub fn get_exprs_from_tts(cx: @ext_ctxt, tts: &[ast::token_tree])
|
|||
-> ~[@ast::expr] {
|
||||
let p = parse::new_parser_from_tts(cx.parse_sess(),
|
||||
cx.cfg(),
|
||||
vec::from_slice(tts));
|
||||
vec::to_owned(tts));
|
||||
let mut es = ~[];
|
||||
while *p.token != token::EOF {
|
||||
if es.len() != 0 {
|
||||
|
|
|
@ -22,7 +22,7 @@ pub fn expand_syntax_ext(cx: @ext_ctxt,
|
|||
cx.print_backtrace();
|
||||
io::stdout().write_line(
|
||||
print::pprust::tt_to_str(
|
||||
ast::tt_delim(vec::from_slice(tt)),
|
||||
ast::tt_delim(vec::to_owned(tt)),
|
||||
cx.parse_sess().interner));
|
||||
|
||||
//trivial expression
|
||||
|
|
|
@ -669,7 +669,7 @@ fn expand_tts(cx: @ext_ctxt,
|
|||
let p = parse::new_parser_from_tts(
|
||||
cx.parse_sess(),
|
||||
cx.cfg(),
|
||||
vec::from_slice(tts)
|
||||
vec::to_owned(tts)
|
||||
);
|
||||
*p.quote_depth += 1u;
|
||||
let tts = p.parse_all_token_trees();
|
||||
|
|
|
@ -25,7 +25,7 @@ pub fn expand_trace_macros(cx: @ext_ctxt,
|
|||
copy cx.parse_sess().span_diagnostic,
|
||||
cx.parse_sess().interner,
|
||||
None,
|
||||
vec::from_slice(tt)
|
||||
vec::to_owned(tt)
|
||||
);
|
||||
let rdr = tt_rdr as @reader;
|
||||
let rust_parser = Parser(
|
||||
|
|
|
@ -82,7 +82,7 @@ pub fn add_new_extension(cx: @ext_ctxt,
|
|||
io::println(fmt!("%s! { %s }",
|
||||
cx.str_of(name),
|
||||
print::pprust::tt_to_str(
|
||||
ast::tt_delim(vec::from_slice(arg)),
|
||||
ast::tt_delim(vec::to_owned(arg)),
|
||||
cx.parse_sess().interner)));
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ pub fn add_new_extension(cx: @ext_ctxt,
|
|||
s_d,
|
||||
itr,
|
||||
None,
|
||||
vec::from_slice(arg)
|
||||
vec::to_owned(arg)
|
||||
) as @reader;
|
||||
match parse(cx.parse_sess(), cx.cfg(), arg_rdr, (*mtcs)) {
|
||||
success(named_matches) => {
|
||||
|
|
Loading…
Reference in a new issue