Hi, all. I'm trying to wrap my head around static dispatch and not having much success.
Basically, I have some trait that takes a const generic and a few implementations of that trait which I'd like to choose between at runtime depending on how the program is called. (playground)
There are a few issues here:
- "
match
arms return incompatible types." How can I return different implementations of T from the same factory function if not throughmatch
? - "trait
T<I>
is not implemented for PathA." (How) can I abstract away the trait's const generic while keeping the associated function interface? I think this is the real roadblock. I've tried switching to associated consts, which feels like a more semantic fit for my application but the language support isn't yet there. But I can use both PathA and PathB interchangeably if I instantiate them manually, so it seems there must be a way...?