Lifetime Constraints on Slices of Slices

No, I don't think that it is the same situation here. How long the reference can live is part of the reference, and that is how it should be. It would have been a comparable mistake if the 'a was somehow tied to the variable name, not the reference. The variable can just contain a value that lives longer than the variable itself.

In fact there isn't any requirement that 'a is the full lifetime of the data it points to. It can be shorter than that. You might like this post of mine.

1 Like