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);

0 commit comments

Comments
 (0)