Here is an offending example:
// Some traits
trait Behaviour {
type Sub: SubBehaviour;
}
trait SubBehaviour {}
// Some implementations of these traits
s
You need to specify the associated type of the trait (i.e. Behavior).
When adding the associated type at all places, it compiles:
struct Example<'a, S: SubBehaviour + 'a> {
behaviours: Vec<&'a Behaviour>,
}
impl<'a, S: SubBehaviour> Example<'a, S> {
fn add_behaviour>(&mut self, b: &'a T) {
self.behaviours.push(b);
}
}
See this in action on the Playground