2012-04-26 18:02:01 -05:00
|
|
|
fn borrow(v: &int, f: fn(x: &int)) {
|
|
|
|
f(v);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn box_imm() {
|
|
|
|
let mut v = ~3;
|
2012-06-30 18:19:07 -05:00
|
|
|
do borrow(v) |w| { //! NOTE loan of mutable local variable granted here
|
2012-06-15 14:24:12 -05:00
|
|
|
v = ~4; //! ERROR assigning to mutable variable declared in an outer block prohibited due to outstanding loan
|
2012-04-26 18:02:01 -05:00
|
|
|
assert *v == 3;
|
|
|
|
assert *w == 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
}
|