▲ | pyrale 3 days ago | |||||||||||||||||||||||||||||||
The hard problem is not sharing the trait, but sharing the trait instance. With your solution, if too modules define traits with identical type signatures but different implementations, it would be impossible for the compiler to decide which impl to use. | ||||||||||||||||||||||||||||||||
▲ | zk4x 3 days ago | parent [-] | |||||||||||||||||||||||||||||||
If there are two modules module_a and module_b, and each defines a function called foo, how does the compiler decide which foo should be used? It just checks whether you imported module_a::foo or module_b::foo. | ||||||||||||||||||||||||||||||||
|