]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #13963 : kballard/rust/remove_owned_vec_from_iterator, r=pcwalton
authorbors <bors@rust-lang.org>
Fri, 9 May 2014 04:01:42 +0000 (21:01 -0700)
committerbors <bors@rust-lang.org>
Fri, 9 May 2014 04:01:42 +0000 (21:01 -0700)
With `~[T]` no longer growable, the `FromIterator` impl for `~[T]` doesn't make
much sense. Not only that, but nearly everywhere it is used is to convert from
a `Vec<T>` into a `~[T]`, for the sake of maintaining existing APIs. This turns
out to be a performance loss, as it means every API that returns `~[T]`, even a
supposedly non-copying one, is in fact doing extra allocations and memcpy's.
Even `&[T].to_owned()` is going through `Vec<T>` first.

Remove the `FromIterator` impl for `~[T]`, and adjust all the APIs that relied
on it to start using `Vec<T>` instead. This includes rewriting
`&[T].to_owned()` to be more efficient, among other performance wins.

Also add a new mechanism to go from `Vec<T>` -> `~[T]`, just in case anyone
truly needs that, using the new trait `FromVec`.

[breaking-change]


Trivial merge