pub trait Downcast: AsAny {
// Provided methods
fn is<T>(&self) -> bool
where T: AsAny { ... }
fn downcast_ref<T>(&self) -> Option<&T>
where T: AsAny { ... }
fn downcast_mut<T>(&mut self) -> Option<&mut T>
where T: AsAny { ... }
}Expand description
This is a shim around AaAny to avoid some boilerplate code.
It is a separate trait because it is also implemented
on runtime polymorphic traits (which are !Sized).
Provided Methods§
Sourcefn is<T>(&self) -> boolwhere
T: AsAny,
fn is<T>(&self) -> boolwhere
T: AsAny,
Returns true if the boxed type is the same as T.
Forward to the method defined on the type Any.
Sourcefn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
Forward to the method defined on the type Any.
Sourcefn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
Forward to the method defined on the type Any.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".