the.bay.news

Questions about the borrow checker's strictness

The Rust Programming Language Forum
Questions about the borrow checker's strictness
I don't really understand why the borrow checker only allows one mutable reference at a time. Doing research, the main example is that it breaks iterators like this, because the internal counter will be invalidated. let mut elements = vec![1, 2, 3]; for v in elements { if v % 2 == 0 { elements.push(0); } } But it feels more like a specific typing issue rather than a problem the borrow checker needs to fix. If the iterator knows that the Vec, in this case is mutable, it should have to use...

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.