Hi Rustaceans, I am a C++ developer looking for some answers from the world of Rust. I am basically trying to implement loose coupling of sw components in a project where dynamic polymorphism is not allowed for performance reasons. To me this sounds very rust-ish.
My primary reason for doing this is to be able to mock and stub the component interfaces for automatic testing, and normally I would use abstract base classes for interfaces and inject the components into each other as depencencies.
So to the question… is it possible using basic language features to create two structs that both implement traits that are used by the other, inject the structs as dependencies to each other and also be able to stub or mock these structs?
I think this sounds possible. If you don’t use a Box<> or similar container (and instead using something like a dyn trait), you know that the compiler knows the real size of the instance you are passing, so no dynamic polymorphism is being used.
If you post some code here, someone might be able to suggest a Rustish way of doing it?