'a represents a generic lifetime (parameter), it will assume a certain lifetime that can be constrained by
'a represents a generic argument, a hole that’s filled with the concrete lifetime that the former
'a assumes on instantiation of the block, basically.
Instantiation is maybe not the correct word, but I use it to convey “filling in all generic parameters”.
Since the lifetime parameter is defined on the
impl block, all implemented methods can use a generic argument (with the same name) to reference the concrete lifetime. The concrete lifetime will come from the calling context.
In this case
'a is a lifetime used within the
Bar struct. This implies that the lifetime
'a will outlive the structure itself. This can be expressed as a constraint and is implicitly added by the compiler:
'a: Bar<'a>, =
'a: Self, ->
'a has the same-or-bigger scope than the instantiation of
Example code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=a2650ac90bd2c2aafbdc557a854960d2
In Rust, everything has a lifetime.
When working with generics it’s necessary to keep track of a certain lifetime so the compiler can verify soundness. That’s where generic lifetime parameters come into play.
Edit: I had the bounds the other way around. Outlives relationship is defined as
'longer: 'shorter, see https://doc.rust-lang.org/stable/rust-by-example/scope/lifetime/lifetime_bounds.html.