Skip to content

Commit 2329651

Browse files
committed
auto merge of #6503 : sonwow/rust/at_vec-renamed, r=graydon
`str::from_slice` and `vec::from_slice` are changed to `str::to_owned` and `vec::to_owned`. (#6389) Replace `at_vec::from_owned` and `at_vec::from_slice` with `at_vec::to_managed_consume` and `at_vec::to_managed`.
2 parents 8257528 + f11297f commit 2329651

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/libcore/at_vec.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ pub fn from_elem<T:Copy>(n_elts: uint, t: T) -> @[T] {
149149
* Creates and initializes an immutable managed vector by moving all the
150150
* elements from an owned vector.
151151
*/
152-
pub fn from_owned<T>(v: ~[T]) -> @[T] {
152+
pub fn to_managed_consume<T>(v: ~[T]) -> @[T] {
153153
let mut av = @[];
154154
unsafe {
155155
raw::reserve(&mut av, v.len());
@@ -164,7 +164,7 @@ pub fn from_owned<T>(v: ~[T]) -> @[T] {
164164
* Creates and initializes an immutable managed vector by copying all the
165165
* elements of a slice.
166166
*/
167-
pub fn from_slice<T:Copy>(v: &[T]) -> @[T] {
167+
pub fn to_managed<T:Copy>(v: &[T]) -> @[T] {
168168
from_fn(v.len(), |i| v[i])
169169
}
170170

@@ -304,20 +304,20 @@ mod test {
304304
}
305305

306306
#[test]
307-
fn test_from_owned() {
308-
assert!(from_owned::<int>(~[]) == @[]);
309-
assert!(from_owned(~[true]) == @[true]);
310-
assert!(from_owned(~[1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]);
311-
assert!(from_owned(~[~"abc", ~"123"]) == @[~"abc", ~"123"]);
312-
assert!(from_owned(~[~[42]]) == @[~[42]]);
307+
fn test_to_managed_consume() {
308+
assert!(to_managed_consume::<int>(~[]) == @[]);
309+
assert!(to_managed_consume(~[true]) == @[true]);
310+
assert!(to_managed_consume(~[1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]);
311+
assert!(to_managed_consume(~[~"abc", ~"123"]) == @[~"abc", ~"123"]);
312+
assert!(to_managed_consume(~[~[42]]) == @[~[42]]);
313313
}
314314
315315
#[test]
316-
fn test_from_slice() {
317-
assert!(from_slice::<int>([]) == @[]);
318-
assert!(from_slice([true]) == @[true]);
319-
assert!(from_slice([1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]);
320-
assert!(from_slice([@"abc", @"123"]) == @[@"abc", @"123"]);
321-
assert!(from_slice([@[42]]) == @[@[42]]);
316+
fn test_to_managed() {
317+
assert!(to_managed::<int>([]) == @[]);
318+
assert!(to_managed([true]) == @[true]);
319+
assert!(to_managed([1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]);
320+
assert!(to_managed([@"abc", @"123"]) == @[@"abc", @"123"]);
321+
assert!(to_managed([@[42]]) == @[@[42]]);
322322
}
323323
}

src/librustc/middle/astencode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,7 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext,
11081108
dcx.tcx.adjustments.insert(id, adj);
11091109
} else if tag == (c::tag_table_capture_map as uint) {
11101110
let cvars =
1111-
at_vec::from_owned(
1111+
at_vec::to_managed_consume(
11121112
val_dsr.read_to_vec(
11131113
|val_dsr| val_dsr.read_capture_var(xcx)));
11141114
dcx.maps.capture_map.insert(id, cvars);

0 commit comments

Comments
 (0)