3 ms·
> have to take ownership of the whole data type, This isn't the case. They only need to borrow it. A borrowed value isn't allowed to move (the borrow itself ca
by Manishearth 10y ago
> have to take ownership of the whole data type,
This isn't the case. They only need to borrow it. A borrowed value isn't allowed to move (the borrow itself can be copied around and shared within the scope of the borrow), so that works out.
Most Rust iterators only borrow the container or iterator they operate on. It's only explicitly moving iterators like .into_iter() (which extracts elements by-move) that don't.