3 ms·
The immutable borrows also help prevent iterator invalidation in single threaded code when using an iterator.
by boustrophedon 6y ago
The immutable borrows also help prevent iterator invalidation in single threaded code when using an iterator.
- jolux 6y agoYes, exactly. One of my first big fights with the borrow checker was over not realizing I was invalidating an iterator by mutating it by looping over it. Then it clicked for me.