Is there a way to combine multiple traits in order to define a new trait? [duplicate]
Is there a way to combine multiple traits (by inheritance?) in order to define a new trait? I'm looking for something like concepts in C++:
auto concept newConcept<typename T> : concept1<T>, concept2<T>, concept3<T> {};
Suppose I want to make a new trait that inherits from Clone
, Default
and some other traits, is that possible?
Solution 1:
Yep!
trait NewTrait: Clone + Default + OtherTraits {}
impl<T> NewTrait for T where T: Clone + Default + OtherTraits {}