pub struct SameLayout<A, B>(/* private fields */);
Expand description
A proof type, showing two types A
and B
have the same layout.
Implementations§
Source§impl<A, B> SameLayout<A, B>
impl<A, B> SameLayout<A, B>
pub const fn new() -> Option<Self>
Sourcepub fn forget_vec(self, vec: Vec<A>) -> Vec<B>
pub fn forget_vec(self, vec: Vec<A>) -> Vec<B>
‘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.
Sourcepub fn deinit_box(self, boxed: Box<A>) -> (A, Box<MaybeUninit<B>>)
pub fn deinit_box(self, boxed: Box<A>) -> (A, Box<MaybeUninit<B>>)
‘Transmute’ a box by reusing its buffer.
NOTE: for the same flexibility as Vec, forget about the returned A
.
Source§impl<A, B> SameLayout<A, B>
impl<A, B> SameLayout<A, B>
pub const fn array<const N: usize>(self) -> SameLayout<[A; N], [B; N]>
Sourcepub const fn chain<C>(self, _: SameLayout<B, C>) -> SameLayout<A, C>
pub const fn chain<C>(self, _: SameLayout<B, C>) -> SameLayout<A, C>
Apply a transitive argument to construct a new relation proof.
Sourcepub const fn transpose(self) -> SameLayout<B, A>
pub const fn transpose(self) -> SameLayout<B, A>
Use commutativity of equality.
Trait Implementations§
Source§impl<A, B> Clone for SameLayout<A, B>
impl<A, B> Clone for SameLayout<A, B>
impl<A, B> Copy for SameLayout<A, B>
impl<A: Eq, B: Eq> Eq for SameLayout<A, B>
impl<A, B> StructuralPartialEq for SameLayout<A, B>
Auto Trait Implementations§
impl<A, B> Freeze for SameLayout<A, B>
impl<A, B> RefUnwindSafe for SameLayout<A, B>where
A: RefUnwindSafe,
B: RefUnwindSafe,
impl<A, B> Send for SameLayout<A, B>
impl<A, B> Sync for SameLayout<A, B>
impl<A, B> Unpin for SameLayout<A, B>
impl<A, B> UnwindSafe for SameLayout<A, B>where
A: UnwindSafe,
B: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more