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
trait MyTrait {
fn my_check(&self) -> bool;
}
trait MyOtherTrait {
fn my_other_check(&self) -> bool;
}
struct Problem<C> {
data: C,
}
trait SetData {
fn set_data(&mut self);
}
impl<C: MyTrait> SetData for Problem<C> {
fn set_data(&mut self) {
// do something
}
}
impl<C: MyTrait + MyOtherTrait> SetData for Problem<C> {
fn set_data(&mut self) {
// do something else
}
}
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.
Thanks
Karl