In the Rust documentation they give this example of how structs need lifetimes when they contain references:
struct Foo<'a> {
x: &'a i32,
}
because
We need to ensure that any reference to a
Foo
cannot outlive the reference to ani32
it contains.
My question is: shouldn't that be implicit? When would we ever not care about an instance of our struct outliving a reference it contains?
Rust already has lifetime elision rules for functions and methods so that we don't have to explicitly declare lifetime constraints. Why don't they have similar elision rules for structs?