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