Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/libcore/at_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ pub fn from_elem<T:Copy>(n_elts: uint, t: T) -> @[T] {
* Creates and initializes an immutable managed vector by moving all the
* elements from an owned vector.
*/
pub fn from_owned<T>(v: ~[T]) -> @[T] {
pub fn to_managed_consume<T>(v: ~[T]) -> @[T] {
let mut av = @[];
unsafe {
raw::reserve(&mut av, v.len());
Expand All @@ -164,7 +164,7 @@ pub fn from_owned<T>(v: ~[T]) -> @[T] {
* Creates and initializes an immutable managed vector by copying all the
* elements of a slice.
*/
pub fn from_slice<T:Copy>(v: &[T]) -> @[T] {
pub fn to_managed<T:Copy>(v: &[T]) -> @[T] {
from_fn(v.len(), |i| v[i])
}

Expand Down Expand Up @@ -304,20 +304,20 @@ mod test {
}

#[test]
fn test_from_owned() {
assert!(from_owned::<int>(~[]) == @[]);
assert!(from_owned(~[true]) == @[true]);
assert!(from_owned(~[1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]);
assert!(from_owned(~[~"abc", ~"123"]) == @[~"abc", ~"123"]);
assert!(from_owned(~[~[42]]) == @[~[42]]);
fn test_to_managed_consume() {
assert!(to_managed_consume::<int>(~[]) == @[]);
assert!(to_managed_consume(~[true]) == @[true]);
assert!(to_managed_consume(~[1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]);
assert!(to_managed_consume(~[~"abc", ~"123"]) == @[~"abc", ~"123"]);
assert!(to_managed_consume(~[~[42]]) == @[~[42]]);
}
#[test]
fn test_from_slice() {
assert!(from_slice::<int>([]) == @[]);
assert!(from_slice([true]) == @[true]);
assert!(from_slice([1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]);
assert!(from_slice([@"abc", @"123"]) == @[@"abc", @"123"]);
assert!(from_slice([@[42]]) == @[@[42]]);
fn test_to_managed() {
assert!(to_managed::<int>([]) == @[]);
assert!(to_managed([true]) == @[true]);
assert!(to_managed([1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]);
assert!(to_managed([@"abc", @"123"]) == @[@"abc", @"123"]);
assert!(to_managed([@[42]]) == @[@[42]]);
}
}
2 changes: 1 addition & 1 deletion src/librustc/middle/astencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext,
dcx.tcx.adjustments.insert(id, adj);
} else if tag == (c::tag_table_capture_map as uint) {
let cvars =
at_vec::from_owned(
at_vec::to_managed_consume(
val_dsr.read_to_vec(
|val_dsr| val_dsr.read_capture_var(xcx)));
dcx.maps.capture_map.insert(id, cvars);
Expand Down