1 A reference has a longer lifetime than the data it references.
3 Erroneous code example:
14 impl<'a, 'b> Trait<'a, 'b> for usize {
15 type Out = &'a Foo<'b>; // error!
19 Here, the problem is that the compiler cannot be sure that the `'b` lifetime
20 will live longer than `'a`, which should be mandatory in order to be sure that
21 `Trait::Out` will always have a reference pointing to an existing type. So in
22 this case, we just need to tell the compiler than `'b` must outlive `'a`:
33 impl<'a, 'b: 'a> Trait<'a, 'b> for usize { // we added the lifetime enforcement
34 type Out = &'a Foo<'b>; // it now works!