Skip to content

Commit b7da975

Browse files
committed
renamed vec::from_slice to vec::to_owned
1 parent ad8e236 commit b7da975

File tree

21 files changed

+39
-39
lines changed

21 files changed

+39
-39
lines changed

src/libcore/rand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ impl<R: Rng> RngUtil for R {
568568

569569
/// Shuffle a vec
570570
fn shuffle<T:Copy>(&mut self, values: &[T]) -> ~[T] {
571-
let mut m = vec::from_slice(values);
571+
let mut m = vec::to_owned(values);
572572
self.shuffle_mut(m);
573573
m
574574
}

src/libcore/vec.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ pub fn from_elem<T:Copy>(n_elts: uint, t: T) -> ~[T] {
166166
}
167167

168168
/// Creates a new unique vector with the same contents as the slice
169-
pub fn from_slice<T:Copy>(t: &[T]) -> ~[T] {
169+
pub fn to_owned<T:Copy>(t: &[T]) -> ~[T] {
170170
from_fn(t.len(), |i| t[i])
171171
}
172172

@@ -3451,19 +3451,19 @@ mod tests {
34513451
let mut results: ~[~[int]];
34523452

34533453
results = ~[];
3454-
for each_permutation(~[]) |v| { results.push(from_slice(v)); }
3454+
for each_permutation(~[]) |v| { results.push(to_owned(v)); }
34553455
assert!(results == ~[~[]]);
34563456

34573457
results = ~[];
3458-
for each_permutation(~[7]) |v| { results.push(from_slice(v)); }
3458+
for each_permutation(~[7]) |v| { results.push(to_owned(v)); }
34593459
assert!(results == ~[~[7]]);
34603460

34613461
results = ~[];
3462-
for each_permutation(~[1,1]) |v| { results.push(from_slice(v)); }
3462+
for each_permutation(~[1,1]) |v| { results.push(to_owned(v)); }
34633463
assert!(results == ~[~[1,1],~[1,1]]);
34643464

34653465
results = ~[];
3466-
for each_permutation(~[5,2,0]) |v| { results.push(from_slice(v)); }
3466+
for each_permutation(~[5,2,0]) |v| { results.push(to_owned(v)); }
34673467
assert!(results ==
34683468
~[~[5,2,0],~[5,0,2],~[2,5,0],~[2,0,5],~[0,5,2],~[0,2,5]]);
34693469
}

src/librust/rust.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ fn do_command(command: &Command, args: &[~str]) -> ValidUsage {
192192
let (prog, prog_args) = (words.head(), words.tail());
193193
let exitstatus = run::run_program(
194194
*prog,
195-
vec::append(vec::from_slice(prog_args), args)
195+
vec::append(vec::to_owned(prog_args), args)
196196
);
197197
os::set_exit_status(exitstatus);
198198
Valid

src/librustc/metadata/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ pub fn maybe_get_item_ast(intr: @ident_interner, cdata: cmd, tcx: ty::ctxt,
580580
let item_doc = lookup_item(id, cdata.data);
581581
let path = {
582582
let item_path = item_path(intr, item_doc);
583-
vec::from_slice(item_path.init())
583+
vec::to_owned(item_path.init())
584584
};
585585
match decode_inlined_item(cdata, tcx, copy path, item_doc) {
586586
Some(ref ii) => csearch::found((/*bad*/copy *ii)),

src/librustc/metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1420,7 +1420,7 @@ pub fn encode_metadata(parms: EncodeParams, crate: &crate) -> ~[u8] {
14201420
//
14211421
// Should be:
14221422
//
1423-
// vec::from_slice(metadata_encoding_version) +
1423+
// vec::to_owned(metadata_encoding_version) +
14241424
14251425
let writer_bytes: &mut ~[u8] = wr.bytes;
14261426

src/librustc/middle/check_match.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
488488
match cx.tcx.def_map.find(&pat_id) {
489489
Some(&def_variant(_, id)) => {
490490
if variant(id) == *ctor_id {
491-
Some(vec::from_slice(r.tail()))
491+
Some(vec::to_owned(r.tail()))
492492
} else {
493493
None
494494
}
@@ -507,7 +507,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
507507
_ => fail!(~"type error")
508508
};
509509
if match_ {
510-
Some(vec::from_slice(r.tail()))
510+
Some(vec::to_owned(r.tail()))
511511
} else {
512512
None
513513
}
@@ -538,7 +538,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
538538
_ => fail!(~"type error")
539539
};
540540
if match_ {
541-
Some(vec::from_slice(r.tail()))
541+
Some(vec::to_owned(r.tail()))
542542
} else {
543543
None
544544
}
@@ -548,7 +548,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
548548
Some(args) => args,
549549
None => vec::from_elem(arity, wild())
550550
};
551-
Some(vec::append(args, vec::from_slice(r.tail())))
551+
Some(vec::append(args, vec::to_owned(r.tail())))
552552
}
553553
def_variant(_, _) => None,
554554
@@ -560,7 +560,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
560560
Some(args) => new_args = args,
561561
None => new_args = vec::from_elem(arity, wild())
562562
}
563-
Some(vec::append(new_args, vec::from_slice(r.tail())))
563+
Some(vec::append(new_args, vec::to_owned(r.tail())))
564564
}
565565
_ => None
566566
}
@@ -578,7 +578,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
578578
_ => wild()
579579
}
580580
});
581-
Some(vec::append(args, vec::from_slice(r.tail())))
581+
Some(vec::append(args, vec::to_owned(r.tail())))
582582
} else {
583583
None
584584
}
@@ -608,7 +608,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
608608
_ => wild()
609609
}
610610
});
611-
Some(vec::append(args, vec::from_slice(r.tail())))
611+
Some(vec::append(args, vec::to_owned(r.tail())))
612612
}
613613
}
614614
}
@@ -627,21 +627,21 @@ pub fn specialize(cx: @MatchCheckCtxt,
627627
single => true,
628628
_ => fail!(~"type error")
629629
};
630-
if match_ { Some(vec::from_slice(r.tail())) } else { None }
630+
if match_ { Some(vec::to_owned(r.tail())) } else { None }
631631
}
632632
pat_range(lo, hi) => {
633633
let (c_lo, c_hi) = match *ctor_id {
634634
val(ref v) => ((/*bad*/copy *v), (/*bad*/copy *v)),
635635
range(ref lo, ref hi) =>
636636
((/*bad*/copy *lo), (/*bad*/copy *hi)),
637-
single => return Some(vec::from_slice(r.tail())),
637+
single => return Some(vec::to_owned(r.tail())),
638638
_ => fail!(~"type error")
639639
};
640640
let v_lo = eval_const_expr(cx.tcx, lo),
641641
v_hi = eval_const_expr(cx.tcx, hi);
642642
let match_ = compare_const_vals(&c_lo, &v_lo) >= 0 &&
643643
compare_const_vals(&c_hi, &v_hi) <= 0;
644-
if match_ { Some(vec::from_slice(r.tail())) } else { None }
644+
if match_ { Some(vec::to_owned(r.tail())) } else { None }
645645
}
646646
pat_vec(before, slice, after) => {
647647
match *ctor_id {
@@ -674,7 +674,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
674674
}
675675
676676
pub fn default(cx: @MatchCheckCtxt, r: &[@pat]) -> Option<~[@pat]> {
677-
if is_wild(cx, r[0]) { Some(vec::from_slice(r.tail())) }
677+
if is_wild(cx, r[0]) { Some(vec::to_owned(r.tail())) }
678678
else { None }
679679
}
680680

src/librustc/middle/trans/adt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ fn mk_struct(cx: @CrateContext, tys: &[ty::t], packed: bool) -> Struct {
217217
size: machine::llsize_of_alloc(cx, llty_rec) /*bad*/as u64,
218218
align: machine::llalign_of_min(cx, llty_rec) /*bad*/as u64,
219219
packed: packed,
220-
fields: vec::from_slice(tys)
220+
fields: vec::to_owned(tys)
221221
}
222222
}
223223

src/librustc/middle/trans/cabi.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ pub impl FnType {
7171
let llretptr = GEPi(bcx, llargbundle, [0u, n]);
7272
let llretloc = Load(bcx, llretptr);
7373
llargvals = ~[llretloc];
74-
atys = vec::from_slice(atys.tail());
75-
attrs = vec::from_slice(attrs.tail());
74+
atys = vec::to_owned(atys.tail());
75+
attrs = vec::to_owned(attrs.tail());
7676
}
7777

7878
while i < n {
@@ -137,8 +137,8 @@ pub impl FnType {
137137
let mut attrs = /*bad*/copy self.attrs;
138138
let mut j = 0u;
139139
let llretptr = if self.sret {
140-
atys = vec::from_slice(atys.tail());
141-
attrs = vec::from_slice(attrs.tail());
140+
atys = vec::to_owned(atys.tail());
141+
attrs = vec::to_owned(attrs.tail());
142142
j = 1u;
143143
get_param(llwrapfn, 0u)
144144
} else if self.ret_ty.cast {

src/librustc/middle/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3813,7 +3813,7 @@ pub fn item_path(cx: ctxt, id: ast::def_id) -> ast_map::path {
38133813
}
38143814

38153815
ast_map::node_variant(ref variant, _, path) => {
3816-
vec::append_one(vec::from_slice(vec::init(*path)),
3816+
vec::append_one(vec::to_owned(vec::init(*path)),
38173817
ast_map::path_name((*variant).node.name))
38183818
}
38193819

src/libstd/flatpipes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ pub mod flatteners {
442442
T: Decodable<D>>(
443443
buf: &[u8])
444444
-> T {
445-
let buf = vec::from_slice(buf);
445+
let buf = vec::to_owned(buf);
446446
let buf_reader = @BufReader::new(buf);
447447
let reader = buf_reader as @Reader;
448448
let mut deser: D = FromReader::from_reader(reader);

src/libstd/getopts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ pub fn getopts(args: &[~str], opts: &[Opt]) -> Result {
339339
}
340340
i += 1;
341341
}
342-
return Ok(Matches {opts: vec::from_slice(opts),
342+
return Ok(Matches {opts: vec::to_owned(opts),
343343
vals: vals,
344344
free: free});
345345
}

src/libstd/md4.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub fn md4(msg: &[u8]) -> Quad {
2626
let orig_len: u64 = (vec::len(msg) * 8u) as u64;
2727

2828
// pad message
29-
let mut msg = vec::append(vec::from_slice(msg), ~[0x80u8]);
29+
let mut msg = vec::append(vec::to_owned(msg), ~[0x80u8]);
3030
let mut bitlen = orig_len + 8u64;
3131
while (bitlen + 64u64) % 512u64 > 0u64 {
3232
msg.push(0u8);

src/libstd/num/bigint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ impl BigUint {
541541
/// Creates and initializes an BigUint.
542542
#[inline(always)]
543543
pub fn from_slice(slice: &[BigDigit]) -> BigUint {
544-
return BigUint::new(vec::from_slice(slice));
544+
return BigUint::new(vec::to_owned(slice));
545545
}
546546

547547
/// Creates and initializes an BigUint.

src/libstd/stats.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl<'self> Stats for &'self [f64] {
5252

5353
fn median(self) -> f64 {
5454
assert!(self.len() != 0);
55-
let mut tmp = vec::from_slice(self);
55+
let mut tmp = vec::to_owned(self);
5656
sort::tim_sort(tmp);
5757
if tmp.len() & 1 == 0 {
5858
let m = tmp.len() / 2;

src/libsyntax/attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ pub fn last_meta_item_list_by_name(items: ~[@ast::meta_item], name: &str)
255255

256256
pub fn sort_meta_items(items: &[@ast::meta_item]) -> ~[@ast::meta_item] {
257257
// This is sort of stupid here, converting to a vec of mutables and back
258-
let mut v = vec::from_slice(items);
258+
let mut v = vec::to_owned(items);
259259
do std::sort::quick_sort(v) |ma, mb| {
260260
get_meta_item_name(*ma) <= get_meta_item_name(*mb)
261261
}

src/libsyntax/ext/asm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub fn expand_asm(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
4141
-> base::MacResult {
4242
let p = parse::new_parser_from_tts(cx.parse_sess(),
4343
cx.cfg(),
44-
vec::from_slice(tts));
44+
vec::to_owned(tts));
4545

4646
let mut asm = ~"";
4747
let mut outputs = ~[];

src/libsyntax/ext/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ pub fn get_exprs_from_tts(cx: @ext_ctxt, tts: &[ast::token_tree])
386386
-> ~[@ast::expr] {
387387
let p = parse::new_parser_from_tts(cx.parse_sess(),
388388
cx.cfg(),
389-
vec::from_slice(tts));
389+
vec::to_owned(tts));
390390
let mut es = ~[];
391391
while *p.token != token::EOF {
392392
if es.len() != 0 {

src/libsyntax/ext/log_syntax.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub fn expand_syntax_ext(cx: @ext_ctxt,
2222
cx.print_backtrace();
2323
io::stdout().write_line(
2424
print::pprust::tt_to_str(
25-
ast::tt_delim(vec::from_slice(tt)),
25+
ast::tt_delim(vec::to_owned(tt)),
2626
cx.parse_sess().interner));
2727

2828
//trivial expression

src/libsyntax/ext/quote.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ fn expand_tts(cx: @ext_ctxt,
669669
let p = parse::new_parser_from_tts(
670670
cx.parse_sess(),
671671
cx.cfg(),
672-
vec::from_slice(tts)
672+
vec::to_owned(tts)
673673
);
674674
*p.quote_depth += 1u;
675675
let tts = p.parse_all_token_trees();

src/libsyntax/ext/trace_macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub fn expand_trace_macros(cx: @ext_ctxt,
2525
copy cx.parse_sess().span_diagnostic,
2626
cx.parse_sess().interner,
2727
None,
28-
vec::from_slice(tt)
28+
vec::to_owned(tt)
2929
);
3030
let rdr = tt_rdr as @reader;
3131
let rust_parser = Parser(

src/libsyntax/ext/tt/macro_rules.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pub fn add_new_extension(cx: @ext_ctxt,
8282
io::println(fmt!("%s! { %s }",
8383
cx.str_of(name),
8484
print::pprust::tt_to_str(
85-
ast::tt_delim(vec::from_slice(arg)),
85+
ast::tt_delim(vec::to_owned(arg)),
8686
cx.parse_sess().interner)));
8787
}
8888

@@ -101,7 +101,7 @@ pub fn add_new_extension(cx: @ext_ctxt,
101101
s_d,
102102
itr,
103103
None,
104-
vec::from_slice(arg)
104+
vec::to_owned(arg)
105105
) as @reader;
106106
match parse(cx.parse_sess(), cx.cfg(), arg_rdr, (*mtcs)) {
107107
success(named_matches) => {

0 commit comments

Comments
 (0)