Remove the angle brackets for lifetime

Hello,

I don’t really understand the point of declaring the lifetimes between <>. Lifetimes already appears on the function signature (on its parameters or returned value), or in the declaration of the fields of a struct.

Unlike a template, it’s already clear in the signature that it’s a lifetime because of the quote notation.

It feels like redundant information to me.

Am I missing something ?

It’s possible for the lifetime to be declared as part of a parent struct/scope/impl. Just as with generic T’s, the syntax is to distinguish declaring a new generic lifetime, and using an old one form the parent scope.

3 Likes

Angle brackets are where generic parameters go.

lifetimes are lifetime parameters, and “Generics” are type parameters.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.