[−][src]Trait abi_stable::pointer_trait::ErasedStableDeref
Erases a pointer,casting its referent to ZeroSized<O>
.
This is safe to do because:
-ZeroSized<O>
is a zero-sized type,
-
StableDeref requires that the pointer always have the same layout regardless of its referent.
-
TransmuteElement requires that the pointer either be
!Drop
, or that the pointer uses a vtable with a destructor that knows the original type of the referent
It would not be safe to do this in the other direction,
going from ZeroSized<O>
to any other type,
Provided methods
fn erased(self, _: VariantPhantom<O>) -> Self::TransmutedPtr where
Self::Target: Sized,
Self::Target: Sized,
Example
use abi_stable::{ pointer_trait::ErasedStableDeref, std_types::RBox, reexports::SelfOps, ZeroSized, }; let signed:RBox<ZeroSized< Vec<()> >> =unsafe{ RBox::new(1_i32) .erased(Vec::<()>::T) };
Implementors
impl<P, O> ErasedStableDeref<O> for P where
P: StableDeref + TransmuteElement<ZeroSized<O>>,
[src]
P: StableDeref + TransmuteElement<ZeroSized<O>>,
fn erased(self, _: VariantPhantom<O>) -> Self::TransmutedPtr where
Self::Target: Sized,
[src]
Self::Target: Sized,