I'm trying to create structure Baz
generic over a trait which requires a lifetime:
trait Foo<'a> {
fn foo(&self) -> &'a u8;
}
struct Baz<'a, T: Foo<'a>>(pub T);
Unfortunately the compiler thinks that 'a
in Baz
is useless:
error[E0392]: parameter `'a` is never used
--> src/main.rs:20:12
|
20 | struct Baz<'a, T: Foo<'a>>(pub T);
| ^^ unused type parameter
|
= help: consider removing `'a` or using a marker such as `std::marker::PhantomData`
How can I express the relation of lifetimes between Baz
and the implementors of Foo
?