Error code E0491
A reference has a longer lifetime than the data it references.
Erroneous code example:
ⓘ
Here, the problem is that the compiler cannot be sure that the 'b
lifetime
will live longer than 'a
, which should be mandatory in order to be sure that
Trait::Out
will always have a reference pointing to an existing type. So in
this case, we just need to tell the compiler than 'b
must outlive 'a
: