I want a RwLock, which only holds anything T, while methods calls on T need to be dispatched dynamically. T needs to satisfy a trait for this.
Furthermore, the RwLock will implement one of my traits, but only, if it contains a value of type T.
It is something like an "async strategy pattern".
tldr: (pseudocode)
T; has to implement MyFunctionTrait
Vec<RwLock<T>>; RwLock<T> has to implement MyMethodTrait
I do not care, waht happens with RwLock<Q>because I will never have one.
Below is a playground which shows an example. I could not get it to compile. Can someone fix it for me and tell me, how to do it correctly?
A browser interface to the Rust compiler to experiment with the language