difference between iter and into_iter in rust

- 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.

Hot pastes

free anonymous http proxies
     21750 | Never
free anonymous socks5 proxies
     9809 | Never
maze traversal
     2343 | Never
windows license keys
     1945 | 2022-10-07
hello, world
     1900 | Never
Deep Copy vs Shallow Copy in C#
     1693 | Never
python extract emails from text
     1690 | Never
difference between iter and into_iter in rust
     1455 | Never
bitwise operations
     1284 | Never
flips a line of text so that it appears to be upside-down and mirrored
     1208 | Never