Trait unsize::CoerciblePtr [−][src]
Add unsizing methods to pointer-like types.
Safety
A correct implementation must uphold, when calling replace_ptr
with valid arguments, that the
pointer target and the provenance of the pointer stay unchanged. This allows calling the
coercion of inner fields of wrappers even when an invariant depends on the pointer target.
Associated Types
type Pointee
[src]
The type we point to. This influences which kinds of unsizing are possible.
type Output
[src]
The output type when unsizing the pointee to U
.
Required methods
fn as_sized_ptr(&mut self) -> *mut Self::Pointee
[src]
Get the raw inner pointer.
unsafe fn replace_ptr(self, _: *mut U) -> Self::Output
[src]
Replace the container inner pointer with an unsized version.
Safety
The caller guarantees that the replacement is the same pointer, just a fat pointer variant with a correct tag.
Implementations on Foreign Types
impl<Ptr, U: ?Sized, T> CoerciblePtr<U> for Pin<Ptr> where
Ptr: CoerciblePtr<U, Pointee = T> + DerefMut<Target = T>,
Ptr::Output: DerefMut<Target = U>,
[src]
Ptr: CoerciblePtr<U, Pointee = T> + DerefMut<Target = T>,
Ptr::Output: DerefMut<Target = U>,
type Pointee = T
type Output = Pin<Ptr::Output>
fn as_sized_ptr(&mut self) -> *mut Self::Pointee
[src]
unsafe fn replace_ptr(self, new: *mut U) -> Self::Output
[src]
impl<T, U: ?Sized> CoerciblePtr<U> for NonNull<T>
[src]
type Pointee = T
type Output = NonNull<U>
fn as_sized_ptr(&mut self) -> *mut T
[src]
unsafe fn replace_ptr(self, new: *mut U) -> NonNull<U>
[src]
Implementors
impl<'lt, T, U: ?Sized + 'lt> CoerciblePtr<U> for &'lt T
[src]
type Pointee = T
type Output = &'lt U
fn as_sized_ptr(self: &mut &'lt T) -> *mut T
[src]
unsafe fn replace_ptr(self, new: *mut U) -> &'lt U
[src]
impl<'lt, T, U: ?Sized + 'lt> CoerciblePtr<U> for &'lt mut T
[src]
Safety: Provenance is always the same as self.