#009
Feb 2022
9. Inspecting iterator
Ever wondered how to print while iterating?
Use inspect.
| |
Ever wondered how to print while iterating?
Use inspect.
| |
Use drain to remove specified range from a vector.
| |
What is the difference to call into_iter which returns T ?
into_iter takes the collection by value and consumes it.
drain borrows mutable reference, and returns a drain iterator of elements. If such iterator is dropped without exhausting it, all elements are dropped.
What is the difference between .iter() and .into_iter()?
iter yields &T
into_iter may yield any of T, &T or &mut T based on context.
| |
this works but …
This does not. This results in compile error because cars are moved due to into_iter call.
| |