liveBook · Manning

Into_iter

into_iter is a Rust method that consumes or otherwise transforms a value into an iterator yielding its elements, with ownership determined by the receiver.

How 2 Manning books explain it

Idiomatic Rust

into_iter is a method that consumes a collection or other iterable value and returns an iterator that yields its owned elements.

How it is used
Uses consuming iteration to move items into iterator chains and to give a linked list an owned-item traversal.
How deep it goes
Works through separate iterator structs, `IntoIterator` implementations, and owned-item extraction with `Rc::try_unwrap`.
Examples
Shows a consuming linked-list traversal and vectors consumed to unwrap partitioned parsing results.
What you can do after
Build it from scratch for a linked list, or apply it to move vector elements through iterator chains.

Read how Idiomatic Rust explains into_iter →

Learn Rust in a Month of Lunches

into_iter is a Rust method that converts a collection or other iterable value into an iterator, with item ownership determined by the receiver.

How it is used
Converts vectors into value iterators for loops and iterator chains.
How deep it goes
Works through ownership and vector transformations, but does not explain how to implement `into_iter`.
Examples
Shows vectors transformed into new vectors and two value iterators zipped into a `HashMap`.
What you can do after
Apply it to choose value iteration and recognize when a vector will no longer be available.

Read how Learn Rust in a Month of Lunches explains into_iter →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.