Trait unsize::CoerciblePtr[][src]

pub unsafe trait CoerciblePtr<U: ?Sized>: Sized {
    type Pointee;
    type Output;
    fn as_sized_ptr(&mut self) -> *mut Self::Pointee;
unsafe fn replace_ptr(self, _: *mut U) -> Self::Output; }

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.

Loading content...

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.

Loading content...

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]

type Pointee = T

type Output = Pin<Ptr::Output>

impl<T, U: ?Sized> CoerciblePtr<U> for NonNull<T>[src]

type Pointee = T

type Output = NonNull<U>

Loading content...

Implementors

impl<'lt, T, U: ?Sized + 'lt> CoerciblePtr<U> for &'lt T[src]

type Pointee = T

type Output = &'lt U

impl<'lt, T, U: ?Sized + 'lt> CoerciblePtr<U> for &'lt mut T[src]

Safety: Provenance is always the same as self.

type Pointee = T

type Output = &'lt mut U

Loading content...