I\'m trying to define and implement a trait for a struct. All my implementations with generics and lifetime have problems. This must be a rookie mistake. What am I doing wro
The error messages seem pretty clear to me. They point at a type and state that the type needs a lifetime or a type. Add them:
impl<'a> Bar1<'a> for Foo1<'a> { /* ... */ }
impl<T> Bar2<T> for Foo2<T> { /* ... */ }
impl<'a, T: 'a> Bar3<'a, T> for Foo3<'a, T> { /* ... */ }
This is required because you've created parameterized traits:
pub trait Bar3<'a, T: 'a> {
// ^^^^^^^^^^^
fn baaar(&self);
}
None of the traits you have defined need any kind of generic parameters, so the "real" solution is just to remove them. I assume you've added them for some learning purpose not shown here though.