pub unsafe fn dyn_cast_raw<T: SupportsInterfaces + ?Sized, DynInterface, X: Deref<Target = T>, Y, A>(
x: X,
into_raw_parts: fn(X) -> (*const T, A),
from_raw_parts: unsafe fn(*const DynInterface, A) -> Y,
) -> Option<Y>Expand description
Generic runtime-checking safe cast for immutable smart pointers.
Intended for creating specific casting functions for custom smart pointers.
ยงSafety
The function converts original smart pointer to a (possibly thick) immutable raw pointer using
the into_raw_parts callback,
then forms new thick immutable raw pointer replacing metadata with DynMetadata<DynInterface>,
then calls the from_raw_parts unsafe callback to construct smart pointer from the last pointer.
Calling the dyn_cast_raw_mut function is safe iff this last from_raw_parts call is safe.