So you don’t need to use the associated type in any way via the trait objects? In other words, using your
Foo trait example in this thread, you want to call
get(&self) but ignore the return value? Or something else?
EDIT: so assuming the above is correct, here’s an approach: Playground
The gist is you create a wrapper struct (
Eraser in the playground) that wraps any other
T: Foo generically. It, in turn, implements
Foo but “forgets” the associated type - I used
type Item = () in the example. Then you box these erasers, and end up with
Box<Foo<Item=()>>. The implementation of
get(&self) calls into the inner/wrapped type.
Note, as mentioned before, I had to stub out the
get() impl for Bar because it cannot return a ref to a temp Box; this is a separate issue though, and we can discuss that separately if you’d like.
If the above is not what you need, let’s refine the requirements and iterate on this.