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