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