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