Struct same_alloc::same::SameLayout[][src]

pub struct SameLayout<A, B>(_);

A proof type, showing two types A and B have the same layout.

Implementations

impl<A, B> SameLayout<A, B>[src]

pub const fn new() -> Option<Self>[src]

pub fn forget_vec(self, vec: Vec<A>) -> Vec<B>[src]

‘Transmute’ a vector by reusing its buffer. NOTE: This will forget all elements. You must clear the vector first if they are important, or set_len on the result if you can guarantee that old elements are valid initializers for the new type. This affords more flexibility for the caller as they might want to use As as an initializer for Bs which would be invalid if we dropped them. Manually drain the vector if this is not desirable.

pub fn deinit_box(self, boxed: Box<A>) -> (A, Box<MaybeUninit<B>>)[src]

‘Transmute’ a box by reusing its buffer. NOTE: for the same flexibility as Vec, forget about the returned A.

impl<A, B> SameLayout<A, B>[src]

pub const fn array<const N: usize>(self) -> SameLayout<[A; N], [B; N]>[src]

pub const fn chain<C>(self, _: SameLayout<B, C>) -> SameLayout<A, C>[src]

Apply a transitive argument to construct a new relation proof.

pub const fn transpose(self) -> SameLayout<B, A>[src]

Use commutativity of equality.

Trait Implementations

impl<A, B> Clone for SameLayout<A, B>[src]

impl<A, B> Copy for SameLayout<A, B>[src]

impl<A: Debug, B: Debug> Debug for SameLayout<A, B>[src]

impl<A: Eq, B: Eq> Eq for SameLayout<A, B>[src]

impl<A: Hash, B: Hash> Hash for SameLayout<A, B>[src]

impl<A: PartialEq, B: PartialEq> PartialEq<SameLayout<A, B>> for SameLayout<A, B>[src]

impl<A, B> StructuralEq for SameLayout<A, B>[src]

impl<A, B> StructuralPartialEq for SameLayout<A, B>[src]

Auto Trait Implementations

impl<A, B> Send for SameLayout<A, B> where
    A: Send,
    B: Send

impl<A, B> Sync for SameLayout<A, B> where
    A: Sync,
    B: Sync

impl<A, B> Unpin for SameLayout<A, B> where
    A: Unpin,
    B: Unpin

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.