Use `into_iter()` when an iterator should take ownership of its input and yield owned items. For a collection, this is the consuming counterpart to `iter()`, which yields shared references, and `iter_mut()`, which yields mutable references. Choose it when later operations need to move values out rather than borrow them. section 3.2.4 section 3.3
A custom collection should usually return a separate stateful iterator instead of implementing `Iterator` directly on the collection. An inherent `into_iter(self)` method consumes the collection and returns that iterator. Implementing `IntoIterator` also lets owned, shared-borrowed, and mutably borrowed forms select their corresponding iterators. section 3.2.4
impl<'a, T> IntoIterator for &'a LinkedList<T> {
type IntoIter = Iter<'a, T>;
type Item = &'a T;
fn into_iter(self) -> Self::IntoIter {
self.iter() #1
}
}
impl<'a, T> IntoIterator for &'a mut LinkedList<T> {
type IntoIter = IterMut<'a, T>;
type Item = &'a mut T;
fn into_iter(self) -> Self::IntoIter {
self.iter_mut() #2
}
}
impl<T> IntoIterator for LinkedList<T> { #3
type IntoIter = IntoIter<T>;
type Item = T;
fn into_iter(self) -> Self::IntoIter {
self.into_iter() #4
}
}
The three `IntoIterator` implementations distinguish consuming the linked list from iterating over `&LinkedList` or `&mut LinkedList`. section 3.2.4
Move results out of a vector
After partitioning parsed values, consume each vector to unwrap its results: ```rust let successes: Vec<_> = successes.into_iter().map(Result::unwrap).collect(); let failures: Vec<_> = failures.into_iter().map(Result::unwrap_err).collect(); ``` The resulting vectors contain integers and parse errors, respectively, rather than `Result` wrappers. section 3.2.5
Consuming the collection is not, by itself, a guarantee that a custom iterator can extract every value. In the linked-list implementation, `next()` uses `Rc::try_unwrap` to obtain owned items and returns `None` if unwrapping fails. Take care when shared ownership remains in an iterator design. section 3.2.4
`Result::into_iter()` is another useful case: it yields the `Ok` value when present and nothing for `Err`. That makes `flat_map()` convenient for keeping successful parses, but it silently discards failures. Use `partition()` when both successes and errors matter. section 3.2.5

