Closed
Description
Offending code:
struct Foo {
b: i32,
v: Vec<i32>
}
fn incr(x: &mut i32) {
*x += 1;
}
fn main() {
let mut f = Foo { b: 0, v: vec![1, 2, 3] };
f.v.iter().map(|s| {
incr(&mut f.b);
println!("{}: {}", f.b, s);
}).last();
}
Error: error: cannot borrow
fas mutable because
f.v is also borrowed as immutable
On playpen: http://is.gd/PTXhJq
Version info:
rustc 0.13.0-nightly (d91a015ab 2014-11-14 23:37:27 +0000)
binary: rustc
commit-hash: d91a015ab4c538f02fbbc03dfb08193a381c2e3b
commit-date: 2014-11-14 23:37:27 +0000
host: x86_64-unknown-linux-gnu
release: 0.13.0-nightly
Thanks @bjz for helping me submit this.