Hi. Is it always true that the following two implementations of MyStruct are equivalent? I'm particularly interested in the role of the lifetime parameter <'tcx>.
impl<stuff> is the type level analog of let stuff;. It just declares names for lifetimes or type "variables", so that when you use them later somewhere in the impl, the compiler knows this name is expected and it's not made-up or a typo.
Well, there's more to it than that. Something like this would be forbidden for a regular type parameter:
error[E0207]: the type parameter `A` is not constrained by the impl trait, self type, or predicates
--> src/lib.rs:2:6
|
2 | impl<A> Struct {}
| ^ unconstrained type parameter
...though this is mostly to prevent you from using it inside the impl when it isn't constrained by the trait or type (as this could complicate monomorphization). Lifetimes don't affect monomorphization, so the compiler is far more liberal with how they can be used.