how can I make this compile? Is this even possible? I've created a gist here
The problem is type Storage, how to deal with T here? T can be either XState or YState here, but of course not limited to either of them, imagine ZState.
Oh, I see, you can't do that without some sort of type erasure. typemap handles this well.
The reason this can't work is because you have a number of different types that you want to store in a HashMap, but the HashMap expexts the same type for all it's elements.
In general, generic type is something the trait implementation receives, and associated type denote something that it provides. Take, for example, std::ops traits: they have both the generic type - the right side of the operation, which could be different, and the associated type - the result of the operation, entirely depending on the source types.