I'm having trouble with the borrow checker not "releasing" a mutable borrow.
I have:
let mut data = (1..=100).collect::<Vec<_>>();
let mut c = Canvas::new(10, 10, &mut data);
c.iter_rows_mut(4..7);
c.iter_rows(4..7).collect::<Vec<_>>();
And it's complaining:
error[E0502]: cannot borrow `c` as immutable because it is also borrowed as mutable
--> src/lib.rs:59:9
|
57 | c.iter_rows_mut(4..7);
| - mutable borrow occurs here
58 |
59 | c.iter_rows(4..7).collect::<Vec<_>>();
| ^
| |
| immutable borrow occurs here
| mutable borrow later used here
error: aborting due to previous error
I can understand the problem if I was handing onto a reference related to the mutable call, but that doesn't appear to be the case.
Rust Playground with full code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=de4143ddf57cc8a97e7a884bbe13dfa4