I know that the Deref pattern is considered an anti-pattern and that it doesn’t work well with multiple Deref targets (a problem with multiple inheritance anyway).
I was wondering if overloading casting could be a good solution.
trait Cast<T> {
type output;
fn cast(in: t) -> output;
}
Basically this would mean that the following is possible. Yes I know that it is more code then just selecting the field. But if for whatever reason you wanted to do dynamic cast selection this would be able to facilitate that.