Trait ra_ap_stdx::anymap::Downcast
source · pub trait Downcast {
// Required methods
fn type_id(&self) -> TypeId;
unsafe fn downcast_ref_unchecked<T: 'static>(&self) -> &T;
unsafe fn downcast_mut_unchecked<T: 'static>(&mut self) -> &mut T;
}Expand description
Methods for downcasting from an Any-like trait object.
This should only be implemented on trait objects for subtraits of Any, though you can
implement it for other types and it’ll work fine, so long as your implementation is correct.
Required Methods§
sourceunsafe fn downcast_ref_unchecked<T: 'static>(&self) -> &T
unsafe fn downcast_ref_unchecked<T: 'static>(&self) -> &T
Downcast from &Any to &T, without checking the type matches.
§Safety
The caller must ensure that T matches the trait object, on pain of undefined behaviour.
sourceunsafe fn downcast_mut_unchecked<T: 'static>(&mut self) -> &mut T
unsafe fn downcast_mut_unchecked<T: 'static>(&mut self) -> &mut T
Downcast from &mut Any to &mut T, without checking the type matches.
§Safety
The caller must ensure that T matches the trait object, on pain of undefined behaviour.
Object Safety§
This trait is not object safe.