Closed

Description
You’ll also need explicit lifetimes when working with structs:
from here: https://doc.rust-lang.org/nightly/book/lifetimes.html#in-structs
That seems to say that you always need explicit lifetimes when working with structs, but, that's not true, is it? A quick peek ahead at structs, and lifetimes seem to be implicit there: https://doc.rust-lang.org/nightly/book/structs.html
This As you can see, structs can also have lifetimes.
also made me realize I'm misinterpreting the above sentence.
EDIT: Ok but now I'm not sure again, there's that need
again:
So why do we need a lifetime here? We need to ensure that any reference to a Foo cannot outlive the reference to an i32 it contains.
Metadata
Metadata
Assignees
Labels
No labels