[−][src]Trait abi_stable::pointer_trait::TransmuteElement
Transmutes the element type of this pointer..
Safety for implementor
Implementors of this trait must ensure that:
-
The memory layout of this type is the same regardless of the type of the referent .
-
The pointer type is either
!Drop
(no drop glue either), or it uses a vtable to Drop the referent and deallocate the memory correctly.
Safety for callers
Callers must ensure that:
- References to
T
are compatible with references toSelf::Target
.
Associated Types
type TransmutedPtr: StableDeref<Target = T>
Provided methods
unsafe fn transmute_element(self, _: VariantPhantom<T>) -> Self::TransmutedPtr where
Self::Target: Sized,
Self::Target: Sized,
Transmutes the element type of this pointer..
Safety
Callers must ensure that it is valid to convert from a pointer to Self::Referent
to a pointer to T
.
For example:
It is undefined behavior to create unaligned references ,
therefore transmuting from &u8
to &u16
is UB
if the caller does not ensure that the reference was a multiple of 2.
Example
use abi_stable::{ pointer_trait::TransmuteElement, reexports::SelfOps, std_types::RBox, }; let signed:RBox<u32>=unsafe{ RBox::new(1_i32) .transmute_element(u32::T) };
Implementations on Foreign Types
impl<'a, T: 'a, O: 'a> TransmuteElement<O> for &'a T
[src]
type TransmutedPtr = &'a O
unsafe fn transmute_element(self, _: VariantPhantom<T>) -> Self::TransmutedPtr where
Self::Target: Sized,
[src]
Self::Target: Sized,
impl<'a, T: 'a, O: 'a> TransmuteElement<O> for &'a mut T
[src]
type TransmutedPtr = &'a mut O
unsafe fn transmute_element(self, _: VariantPhantom<T>) -> Self::TransmutedPtr where
Self::Target: Sized,
[src]
Self::Target: Sized,
Implementors
impl<T, O> TransmuteElement<O> for RArc<T>
[src]
type TransmutedPtr = RArc<O>
unsafe fn transmute_element(self, _: VariantPhantom<T>) -> Self::TransmutedPtr where
Self::Target: Sized,
[src]
Self::Target: Sized,
impl<T, O> TransmuteElement<O> for RBox<T>
[src]
type TransmutedPtr = RBox<O>
unsafe fn transmute_element(self, _: VariantPhantom<T>) -> Self::TransmutedPtr where
Self::Target: Sized,
[src]
Self::Target: Sized,