Iter and Into_iter in Rust?fleeting
- External reference: https://stackoverflow.com/questions/34733811/what-is-the-difference-between-iter-and-into-iter
- The iterator returned by into_iter may yield any of T, &T or &mut T, depending on the context.
- The iterator returned by iter will yield &T, by convention.
- The iterator returned by iter_mut will yield &mut T, by convention
- into_iter is a generic method to obtain an iterator, whether this iterator yields values, immutable references or mutable references is context dependent and can sometimes be surprising.
- iter and iter_mut are ad-hoc methods. Their return type is therefore independent of the context, and will conventionally be iterators yielding immutable references and mutable references, respectively