rust/tests/ui/regions/regions-steal-closure.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

18 lines
339 B
Rust
Raw Normal View History

#![feature(fn_traits)]
struct ClosureBox<'a> {
2019-05-28 13:46:13 -05:00
cl: Box<dyn FnMut() + 'a>,
}
2019-05-28 13:46:13 -05:00
fn box_it<'r>(x: Box<dyn FnMut() + 'r>) -> ClosureBox<'r> {
ClosureBox {cl: x}
}
fn main() {
let mut cl_box = {
2015-01-31 10:23:42 -06:00
let mut i = 3;
box_it(Box::new(|| i += 1)) //~ ERROR `i` does not live long enough
};
2015-01-03 09:45:00 -06:00
cl_box.cl.call_mut(());
}