2020-05-20 18:58:41 +01:00
|
|
|
fn with_int<F>(f: F)
|
|
|
|
where
|
|
|
|
F: FnOnce(&isize),
|
|
|
|
{
|
2012-08-13 15:06:13 -07:00
|
|
|
let x = 3;
|
|
|
|
f(&x);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2015-01-08 21:54:35 +11:00
|
|
|
let mut x: Option<&isize> = None;
|
2018-01-03 15:54:33 -08:00
|
|
|
with_int(|y| x = Some(y));
|
2020-05-20 18:58:41 +01:00
|
|
|
//~^ ERROR borrowed data escapes outside of closure
|
2012-08-13 15:06:13 -07:00
|
|
|
}
|