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 18:46:13 +00:00
cl: Box<dyn FnMut() + 'a>,
}
2019-05-28 18:46:13 +00:00
fn box_it<'r>(x: Box<dyn FnMut() + 'r>) -> ClosureBox<'r> {
ClosureBox {cl: x}
}
fn main() {
let mut cl_box = {
2015-01-31 16:23:42 +00:00
let mut i = 3;
box_it(Box::new(|| i += 1)) //~ ERROR `i` does not live long enough
};
2015-01-03 15:45:00 +00:00
cl_box.cl.call_mut(());
}