2015-01-08 04:54:35 -06:00
|
|
|
fn borrow<F>(v: &isize, f: F) where F: FnOnce(&isize) {
|
2012-04-26 18:02:01 -05:00
|
|
|
f(v);
|
|
|
|
}
|
|
|
|
|
2021-08-24 19:39:40 -05:00
|
|
|
|
|
|
|
|
2012-04-26 18:02:01 -05:00
|
|
|
fn box_imm() {
|
2021-08-24 19:39:40 -05:00
|
|
|
let mut v: Box<_> = Box::new(3);
|
2014-07-07 18:35:15 -05:00
|
|
|
borrow(&*v,
|
2014-02-10 06:44:03 -06:00
|
|
|
|w| { //~ ERROR cannot borrow `v` as mutable
|
2021-08-24 19:39:40 -05:00
|
|
|
v = Box::new(4);
|
2014-02-10 06:44:03 -06:00
|
|
|
assert_eq!(*v, 3);
|
|
|
|
assert_eq!(*w, 4);
|
|
|
|
})
|
2012-04-26 18:02:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
}
|