2018-12-17 03:21:47 +00:00
|
|
|
struct Direct<'a> {
|
2015-01-08 10:54:35 +00:00
|
|
|
f: &'a isize
|
2012-08-23 23:22:23 +00:00
|
|
|
}
|
|
|
|
|
2018-12-17 03:21:47 +00:00
|
|
|
struct Indirect1 {
|
2013-02-28 00:41:02 +00:00
|
|
|
// Here the lifetime parameter of direct is bound by the fn()
|
2019-05-28 18:46:13 +00:00
|
|
|
g: Box<dyn FnOnce(Direct) + 'static>
|
2012-08-23 23:22:23 +00:00
|
|
|
}
|
|
|
|
|
2018-12-17 03:21:47 +00:00
|
|
|
struct Indirect2<'a> {
|
2013-12-10 07:16:18 +00:00
|
|
|
// But here it is set to 'a
|
2019-05-28 18:46:13 +00:00
|
|
|
g: Box<dyn FnOnce(Direct<'a>) + 'static>
|
2012-08-23 23:22:23 +00:00
|
|
|
}
|
|
|
|
|
2022-04-19 10:56:18 +00:00
|
|
|
fn take_direct<'a,'b>(p: Direct<'a>) -> Direct<'b> { p }
|
2022-04-01 17:13:25 +00:00
|
|
|
//~^ ERROR lifetime may not live long enough
|
2013-05-24 01:37:37 +00:00
|
|
|
|
2018-12-17 03:21:47 +00:00
|
|
|
fn take_indirect1(p: Indirect1) -> Indirect1 { p }
|
2013-05-24 01:37:37 +00:00
|
|
|
|
2022-04-19 10:56:18 +00:00
|
|
|
fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p }
|
2022-04-01 17:13:25 +00:00
|
|
|
//~^ ERROR lifetime may not live long enough
|
|
|
|
//~| ERROR lifetime may not live long enough
|
2013-05-24 01:37:37 +00:00
|
|
|
|
2012-08-23 23:22:23 +00:00
|
|
|
fn main() {}
|