3 ms·
These two stack overflow discussions helped me with 'into_iter' and move semantics. https://stackoverflow.com/questions/34733811/what-is-the-difference-between
by jacoblambda 6y ago
These two stack overflow discussions helped me with 'into_iter' and move semantics.
https://stackoverflow.com/questions/34733811/what-is-the-difference-between-iter-and-into-iter https://stackoverflow.com/questions/34733811/what-is-the-dif...
https://stackoverflow.com/questions/30288782/what-are-move-semantics-in-rust https://stackoverflow.com/questions/30288782/what-are-move-s...
There are two types of ownership operations in Rust: consume/move and borrow.
A consume or a move is transferring ownership. Consume is often used because it makes more sense in most cases as a word than move. The function is consuming or eating the variable so it is no longer available for another function to consume/eat. The term move comes from the formal system behind the borrow checker, the "Affine type system".
Borrowing is fairly self explanatory. The function isn't eating the value, it's just looking at it or in the 'mut' case, is modifying it in some way(if food is a good analogy, think adding seasoning or removing a crust).
As for 'into_iter', it basically can be defined as a move, borrow, and/or mutable borrow. This let's you set rules on how the data type may be used. This way the type can be used in most language constructs naturally with the compiler picking the best version based on the constraints of the program.
Apologies in advance if you weren't looking for an explanation and I misread the room.