It works
trait CoffieSort { fn drink(&self); } trait ProgrammingLanguage { fn code(&self); } trait JavaJar { fn get(&self) -> impl CoffieSort + ProgrammingLanguage; } but if I wanted to use a dynamic trait
trait JavaJar { fn get(&self) -> &dyn CoffieSort + ProgrammingLanguage; } I would face
I wonder, what were the technical reasons of this limitation? At first glance, nothing prevents compiler from checking it a compile time, so I believe it has something to do with a trait object structure, but from what I see it only has a vtable pointer, and doesn't care about traits.
4 posts - 3 participants

