mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 15:01:51 +00:00
19 lines
314 B
Rust
19 lines
314 B
Rust
fn borrow<F>(v: &isize, f: F) where F: FnOnce(&isize) {
|
|
f(v);
|
|
}
|
|
|
|
|
|
|
|
fn box_imm() {
|
|
let mut v: Box<_> = Box::new(3);
|
|
borrow(&*v,
|
|
|w| { //~ ERROR cannot borrow `v` as mutable
|
|
v = Box::new(4);
|
|
assert_eq!(*v, 3);
|
|
assert_eq!(*w, 4);
|
|
})
|
|
}
|
|
|
|
fn main() {
|
|
}
|