Skip to content

Commit

Permalink
rename at_vec::from_owned and at_vec::from_slice to `at_vec::to_m…
Browse files Browse the repository at this point in the history
…anaged_consume` and `at_vec::to_managed`
  • Loading branch information
sonwow committed May 15, 2013
1 parent 62c7027 commit f11297f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
28 changes: 14 additions & 14 deletions src/libcore/at_vec.rs
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
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

5 comments on commit f11297f

@bors
Copy link
Contributor

@bors bors commented on f11297f May 16, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from graydon
at sonwow@f11297f

@bors
Copy link
Contributor

@bors bors commented on f11297f May 16, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging sonwow/rust/at_vec-renamed = f11297f into auto

@bors
Copy link
Contributor

@bors bors commented on f11297f May 16, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sonwow/rust/at_vec-renamed = f11297f merged ok, testing candidate = 2329651

@bors
Copy link
Contributor

@bors bors commented on f11297f May 16, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on f11297f May 16, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding incoming to auto = 2329651

Please sign in to comment.