I have a trait
T and many implementing structs
S_1, ..., S_n.
Box<dyn T>, how can I figure out if both trait objects are of the same type? I’m not interested in what the actual types are, just if they are the same or not.
My current approach is to add a function
fn id(&self) -> i32 to
T that returns a different constant for each type. But this is labourous and error-prone.
Is there a better way to do this?