Trait munge::Restructure

source ·
pub unsafe trait Restructure<T: ?Sized>: Destructure {
    type Restructured;

    // Required method
    unsafe fn restructure(&self, ptr: *mut T) -> Self::Restructured;
}
Expand description

A type that can be “restructured” as a field of some containing type.

See the crate docs for an example of implementing Destructure and Restructure.

§Safety

restructure must return a valid Restructured that upholds the invariants for its Destructuring:

  • If the type is destructured by borrow, then the Restructured value must behave as a disjoint borrow of a field of the underlying type.
  • If the type is destructured by move, then the Restructured value must move the fields out of the underlying type.

Required Associated Types§

source

type Restructured

The restructured version of this type.

Required Methods§

source

unsafe fn restructure(&self, ptr: *mut T) -> Self::Restructured

Restructures a pointer to this type into the target type.

§Safety

ptr must be a properly aligned pointer to a subfield of the pointer underlying self.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<'a, T, U> Restructure<U> for &'a UnsafeCell<T>
where T: ?Sized, U: 'a + ?Sized,

§

type Restructured = &'a UnsafeCell<U>

source§

unsafe fn restructure(&self, ptr: *mut U) -> Self::Restructured

source§

impl<'a, T, U> Restructure<U> for &'a ManuallyDrop<T>
where T: ?Sized, U: 'a + ?Sized,

§

type Restructured = &'a ManuallyDrop<U>

source§

unsafe fn restructure(&self, ptr: *mut U) -> Self::Restructured

source§

impl<'a, T, U> Restructure<U> for &'a mut UnsafeCell<T>
where T: ?Sized, U: 'a + ?Sized,

§

type Restructured = &'a mut UnsafeCell<U>

source§

unsafe fn restructure(&self, ptr: *mut U) -> Self::Restructured

source§

impl<'a, T, U> Restructure<U> for &'a mut ManuallyDrop<T>
where T: ?Sized, U: 'a + ?Sized,

§

type Restructured = &'a mut ManuallyDrop<U>

source§

unsafe fn restructure(&self, ptr: *mut U) -> Self::Restructured

source§

impl<'a, T, U: 'a> Restructure<U> for &'a MaybeUninit<T>

§

type Restructured = &'a MaybeUninit<U>

source§

unsafe fn restructure(&self, ptr: *mut U) -> Self::Restructured

source§

impl<'a, T, U: 'a> Restructure<U> for &'a mut MaybeUninit<T>

§

type Restructured = &'a mut MaybeUninit<U>

source§

unsafe fn restructure(&self, ptr: *mut U) -> Self::Restructured

source§

impl<'a, T: ?Sized, U: 'a + ?Sized> Restructure<U> for &'a Cell<T>

§

type Restructured = &'a Cell<U>

source§

unsafe fn restructure(&self, ptr: *mut U) -> Self::Restructured

source§

impl<'a, T: ?Sized, U: 'a + ?Sized> Restructure<U> for &'a mut Cell<T>

§

type Restructured = &'a mut Cell<U>

source§

unsafe fn restructure(&self, ptr: *mut U) -> Self::Restructured

source§

impl<T, U> Restructure<U> for Cell<T>

§

type Restructured = Cell<U>

source§

unsafe fn restructure(&self, ptr: *mut U) -> Self::Restructured

source§

impl<T, U> Restructure<U> for UnsafeCell<T>

§

type Restructured = UnsafeCell<U>

source§

unsafe fn restructure(&self, ptr: *mut U) -> Self::Restructured

source§

impl<T, U> Restructure<U> for ManuallyDrop<T>

§

type Restructured = ManuallyDrop<U>

source§

unsafe fn restructure(&self, ptr: *mut U) -> Self::Restructured

source§

impl<T, U> Restructure<U> for MaybeUninit<T>

§

type Restructured = MaybeUninit<U>

source§

unsafe fn restructure(&self, ptr: *mut U) -> Self::Restructured

Implementors§