I am trying to return an object together with a reference to its internal body, e.g.
struct S {
i: i8,
}
fn ret_ref() -> (S, &i8) {
let s = S{i: 3};
(s, &s.i)
}
And the lifetime checker recognized that &i8
might have a shorter lifetime than the original value. now if I return s
together, is there a way to extend the lifetime of the reference?