pub trait DowncastUnchecked<'a> {
type DowncastResult<D: ?Sized + 'a>;
// Required method
unsafe fn downcast_unchecked<D: ?Sized + Pointee>(
self,
metadata: <D as Pointee>::Metadata,
) -> Self::DowncastResult<D>;
}Expand description
A pointer to an object that can be unsafely downcast to point to another type.
Required Associated Types§
Sourcetype DowncastResult<D: ?Sized + 'a>
type DowncastResult<D: ?Sized + 'a>
The result of downcasting this pointer to point to the type D. Note that this type need not have the same outer wrapper as the
type implementing DowncastUnchecked, since the result of the downcast may involve coercions and dereferences.
Required Methods§
Sourceunsafe fn downcast_unchecked<D: ?Sized + Pointee>(
self,
metadata: <D as Pointee>::Metadata,
) -> Self::DowncastResult<D>
unsafe fn downcast_unchecked<D: ?Sized + Pointee>( self, metadata: <D as Pointee>::Metadata, ) -> Self::DowncastResult<D>
Downcasts this pointer into a new pointer pointing to the same object, but having type D.
Generally, the result of calling this function should be equivalent to turning this pointer type into a raw pointer, removing its
metadata, unsafely casting that pointer into a pointer to D using the provided metadata, and then turning that raw pointer into
another pointer type.
As long as the concrete type of the pointee matches the concrete type of the metadata provided, then this is guaranteed to result in a pointer which is valid and safe to use.
§Safety
Attaching the provided metadata to a pointer to the same data address as that held by this pointer must be guaranteed to be valid and safe to use before this function can be called.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.