2016-11-10 17:08:21 +00:00
|
|
|
#![feature(fn_traits)]
|
|
|
|
|
2018-12-17 03:21:47 +00:00
|
|
|
struct ClosureBox<'a> {
|
2019-05-28 18:46:13 +00:00
|
|
|
cl: Box<dyn FnMut() + 'a>,
|
2012-08-20 23:53:33 +00:00
|
|
|
}
|
|
|
|
|
2019-05-28 18:46:13 +00:00
|
|
|
fn box_it<'r>(x: Box<dyn FnMut() + 'r>) -> ClosureBox<'r> {
|
2018-12-17 03:21:47 +00:00
|
|
|
ClosureBox {cl: x}
|
2012-08-20 23:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2015-03-01 00:34:16 +00:00
|
|
|
let mut cl_box = {
|
2015-01-31 16:23:42 +00:00
|
|
|
let mut i = 3;
|
2015-02-15 08:52:21 +00:00
|
|
|
box_it(Box::new(|| i += 1)) //~ ERROR `i` does not live long enough
|
2012-08-20 23:53:33 +00:00
|
|
|
};
|
2015-01-03 15:45:00 +00:00
|
|
|
cl_box.cl.call_mut(());
|
2012-08-20 23:53:33 +00:00
|
|
|
}
|