2019-05-28 13:46:13 -05:00
|
|
|
fn borrowed_proc<'a>(x: &'a isize) -> Box<dyn FnMut()->(isize) + 'a> {
|
2014-08-27 20:46:52 -05:00
|
|
|
// This is legal, because the region bound on `proc`
|
|
|
|
// states that it captures `x`.
|
2015-02-15 02:52:21 -06:00
|
|
|
Box::new(move|| { *x })
|
2014-05-02 13:04:26 -05:00
|
|
|
}
|
|
|
|
|
2020-05-29 20:05:20 -05:00
|
|
|
fn static_proc(x: &isize) -> Box<dyn FnMut() -> (isize) + 'static> {
|
2014-08-27 20:46:52 -05:00
|
|
|
// This is illegal, because the region bound on `proc` is 'static.
|
2022-04-19 05:56:18 -05:00
|
|
|
Box::new(move || { *x })
|
2022-04-01 12:13:25 -05:00
|
|
|
//~^ ERROR lifetime may not live long enough
|
2014-05-02 13:04:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() { }
|