devela::_dep::rkyv::munge

Trait Restructure

pub unsafe trait Restructure<T>: Destructure
where T: ?Sized,
{ type Restructured; // Required method unsafe fn restructure(&self, ptr: *mut T) -> Self::Restructured; }
Available on crate feature dep_rkyv only.
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§

type Restructured

The restructured version of this type.

Required Methods§

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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

§

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

§

type Restructured = &'a Cell<U>

§

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

§

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

§

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

§

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

§

type Restructured = &'a mut Cell<U>

§

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

§

type Restructured = &'a mut ManuallyDrop<U>

§

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

§

type Restructured = &'a mut UnsafeCell<U>

§

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

§

type Restructured = &'a mut MaybeUninit<U>

§

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

§

type Restructured = Seal<'a, U>

§

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

§

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

§

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

§

impl<T, U> Restructure<U> for Place<T>
where T: ?Sized, U: ?Sized,

§

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