]> git.lizzy.rs Git - rust.git/commit
Remove FromIterator impl for ~[T]
authorKevin Ballard <kevin@sb.org>
Sat, 3 May 2014 23:11:12 +0000 (16:11 -0700)
committerKevin Ballard <kevin@sb.org>
Thu, 8 May 2014 19:06:21 +0000 (12:06 -0700)
commitbf1e065371f8e50f84318b45fb21a949faa9449f
tree44bc8d446e0fa05b767cb4c5245c87510a69576a
parentaa6725407ae0a2cb88458e147e76adf8bcae0961
Remove FromIterator impl for ~[T]

As part of the shift from ~[T] to Vec<T>, recently ~[T] was made
non-growable. However, the FromIterator implementation for ~[T] was left
intact (albeit implemented inefficiently), which basically provided a
loophole to grow a ~[T] despite its non-growable nature. This is a
problem, both for performance reasons and because it encourages APIs to
continue returning ~[T] when they should return Vec<T>. Removing
FromIterator forces these APIs to adopt the correct type.

Furthermore, during today's weekly meeting it was decided that we should
remove all instances of ~[T] from the standard libraries in favor of
Vec<T>. Removing the FromIterator impl makes sense to do as a result.

This commit only includes the removal of the FromIterator impl. The
subsequent commits involve handling all of the breakage that results,
including changing APIs to use Vec<T> instead of ~[T]. The precise API
changes are documented in the subsequent commit messages, but each
commit is not individually marked as a breaking change.

Finally, a new trait FromVec is introduced that provides a mechanism to
convert Vec<T> back into ~[T] if truly necessary. It is a bit awkward to
use by design, and is anticipated that it will be more useful in a
post-DST world to convert to an arbitrary Foo<[T]> smart pointer.

[breaking-change]
src/libcore/should_not_exist.rs