Hi there, I am having some difficult in trying to implement a trait for a struct which has generics, but having slightly different code for the same method name. Below is an example of what I am trying to achieve
Problem is my struct with a generic C and I want to implement the SetData trait, but do so slightly differently for when the generic C has the trait MyTrait and for when it has MyTrait and MyOtherTrait.
Any help on how to navigate around this problem would be much appreciated.
This is called specialization and it's not currently possible: if you think about it, the second impl includes the first one, so which one should apply to a type that satisfies both?
You will have to re-define the problem. What is the higher-level problem you are trying to solve? There might be a completely different, easier solution.
It makes sense about what you said about which one should apply; I wasnt sure if internally it would only invoke the one with two traits if they were both present.
I have some other code that will take the struct problem and call the method set_data, but i just want the method to be slightly different for the trait different traits