Barring the two small fixes (making the struct TheirPoint and the type parameter T Copy) needed to make the code compilable, you need to specify that the impl of MyCenter and TheirShadow for T specify the same associated types. In other words, <T as MyCenter>::Input must equal <T as TheirShadow>::Output. Without this specification, there is no way for the compiler to know if the type of the value returned by self.graph.cast_shadow (i.e. the type of the bindingshadowOfGraph) is the same as the type of the parameter to self.graph.center.

This can be done by adding an additional type parameter S to the MyCalculate impl to hold the type that both these associated types must be assigned to:

impl<S, T> MyCalculate for MyDrawing<T> 
    where T: TheirShadow<Output=S> + MyCenter<Input=S>

Rust playground (with the Copy fixes)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top