2 ms·
If I recall correctly, Rust decisively wanted to avoid multiple inheritance concept, in order not to deal with the diamond problem. Composition over inheritanc
by shmerl 2y ago
If I recall correctly, Rust decisively wanted to avoid multiple inheritance concept, in order not to deal with the diamond problem.
Composition over inheritance is the suggested principle.
- ameliaquining 2y agoThis is not really related to the problems that the article is talking about. Rust doesn't have implementation inheritance at all, single or multiple, and "diamond impls" are prevented by the orphan rule. A type implementing multiple traits is fine and normal, as is a type bound that requires type parameters to implement multiple traits; none of this poses any "diamond inheritance" type issues or other conceptual problems. It's only if you want to do dynamic dispatch in this situation that there are problems, because dynamic dispatch requires vtables and it's not clear how vtables for multiple traits would work; all known design proposals have serious drawbacks.