I just came across the limitation that trait objects cannot have methods with type parameters.
Coming from JVM languages, this is a really harsh limitation.
Are there "workarounds" I'm possibly missing?
(Context: My Services are trait objects. They need dynamic dispatch because, for one thing, for DI you need to be able to use test impls as well. And I want/need to have methods that are generic over certain types.)
I wouldn't use trait objects for either DI or genericity. They're too limiting for that, and you likely don't need the things they do offer.
For DI, I'd generally use a normal type parameter. That is, supposing I have a type Mailer which has a dependency that requires an implementation of Transport, I would generally default to impl<T> Mailer<T> where T: Transport, using T for the type of the transport, rather than impl Mailer, using &dyn Transport or Box<dyn Transport> for the transport.
Your tests would run against, say, Mailer<InMemory>, while the running application might use Mailer<Smtp>.
The one place trait objects are truly hard to avoid (and usually worthwhile) is in heterogeneous collections of values implementing a common trait, where there isn't necessarily any single type (other than the trait object type) that you could be using.
Can you give a more concrete example of how your code uses trait objects?