When downcasting in Rust, you (attempt to) downcast to the erased type. In that snippet, you would only be able to successfully downcast to a TabBar
.
You can switch between dyn Trait
types like so. But I'm not sure this actually accomplishes anything you're trying to do.
As for why Rc::downcast
is called that way, it's due to its smart-pointer nature:
The inherent methods of
Rc
are all associated functions, which means that you have to call them as e.g.,Rc::get_mut(&mut value)
instead ofvalue.get_mut()
. This avoids conflicts with methods of the inner typeT
.