2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2018-08-31 08:02:01 -05:00
|
|
|
#![allow(non_camel_case_types)]
|
|
|
|
|
2013-12-10 01:16:18 -06:00
|
|
|
struct closure_box<'a> {
|
2019-05-28 13:47:21 -05:00
|
|
|
cl: Box<dyn FnMut() + 'a>,
|
2012-08-20 18:53:33 -05:00
|
|
|
}
|
|
|
|
|
2019-05-28 13:47:21 -05:00
|
|
|
fn box_it<'a>(x: Box<dyn FnMut() + 'a>) -> closure_box<'a> {
|
2013-02-15 04:44:18 -06:00
|
|
|
closure_box {cl: x}
|
2012-08-20 18:53:33 -05:00
|
|
|
}
|
|
|
|
|
2015-01-02 16:32:54 -06:00
|
|
|
fn call_static_closure(mut cl: closure_box<'static>) {
|
2015-12-02 19:31:49 -06:00
|
|
|
(cl.cl)();
|
2012-08-20 18:53:33 -05:00
|
|
|
}
|
|
|
|
|
2013-02-01 21:43:17 -06:00
|
|
|
pub fn main() {
|
2015-02-15 02:52:21 -06:00
|
|
|
let cl_box = box_it(Box::new(|| println!("Hello, world!")));
|
2013-02-15 04:44:18 -06:00
|
|
|
call_static_closure(cl_box);
|
2012-08-20 18:53:33 -05:00
|
|
|
}
|