Skip to content

core::at_vec should have from_owned and from_slice functions #4553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Dretch opened this issue Jan 20, 2013 · 1 comment
Closed

core::at_vec should have from_owned and from_slice functions #4553

Dretch opened this issue Jan 20, 2013 · 1 comment

Comments

@Dretch
Copy link
Contributor

Dretch commented Jan 20, 2013

Currently core::at_vec has constructor functions including build, build_sized, build_sized_opt, from_fn and from_elem.

As far as I understand, none of these allow constructing an @vec by moving (rather than copying) all the values from a ~vec.

Therefore, I think it would be good if core::at_vec gained a function like:

pub fn from_owned<T>(v: ~[T]) -> @[T] { ... }

and, for convenience, something like this too:

pub fn from_slice<T:Copy>(v: &[T]) -> @[T] { ... }

Is this proposal something desirable? If so I will try and submit code/docs/tests.

catamorphism added a commit that referenced this issue Jan 22, 2013
Add more constructors for managed vectors (as proposed in issue #4553)
@catamorphism
Copy link
Contributor

I merged @Dretch 's change in 519b60f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants