d264ef2b11
`IntoIterator` now has an extra associated item: ``` rust trait IntoIterator { type Item; type IntoIter: Iterator<Self=Self::Item>; } ``` This lets you bind the iterator \"`Item`\" directly when writing generic functions: ``` rust // hypothetical change, not included in this PR impl Extend<T> for Vec<T> { // you can now write fn extend<I>(&mut self, it: I) where I: IntoIterator<Item=T> { .. } // instead of fn extend<I: IntoIterator>(&mut self, it: I) where I::IntoIter: Iterator<Item=T> { .. } } ``` The downside is that now you have to write an extra associated type in your `IntoIterator` implementations: ``` diff impl<T> IntoIterator for Vec<T> { + type Item = T; type IntoIter = IntoIter<T>; fn into_iter(self) -> IntoIter<T> { .. } } ``` Because this breaks all downstream implementations of `IntoIterator`, this is a [breaking-change] --- r? @aturon |
||
---|---|---|
.. | ||
btree | ||
bench.rs | ||
binary_heap.rs | ||
bit.rs | ||
dlist.rs | ||
enum_set.rs | ||
fmt.rs | ||
lib.rs | ||
macros.rs | ||
ring_buf.rs | ||
slice.rs | ||
str.rs | ||
string.rs | ||
vec_map.rs | ||
vec.rs |