Module same_alloc::same [−][src]
Contains a proof type, demonstrating the layout equality of two types.
This is relevant to allocated containers as well as other reuse of raw memory since layout
equality guarantees certain types of soundness. For example, the memory allocated for a
Box<A>
can be reused for storing a type B
exactly if those two types have the same layout.
The module defines a number of helpers (for_*
) that guarantee construction. Also note that
most of the methods are usable in const
contexts. Albeit, in practice you might need to use a
generic lifetime parameter in one of your proofs but this is not possible in constants.
Instead, wait for const {}
blocks to stabilize.
Structs
SameLayout | A proof type, showing two types |
Functions
for_box | A proof that any box has same layout as a raw pointer. |
for_box_opt | A proof that any optional box has same layout as a raw pointer. |
for_mut | A proof that any mutable reference has same layout as a raw pointer. FIXME: this is not const because of the very narrow formulation of https://github.com/rust-lang/rust/issues/57349 |
for_mut_opt | A proof that any option wrapped mutable reference has same layout as an pure reference. FIXME: this is not const because of the very narrow formulation of https://github.com/rust-lang/rust/issues/57349 |
for_non_null | A proof that a non-null pointer has the same layout as a raw pointer. |
for_non_null_opt | A proof that an option of a non-null pointer has the same layout as a raw pointer. |
for_ptr_mut | A proof that mutable pointer has the same layout as a const pointer. |
for_ref | A proof that any reference has same layout as a raw pointer. |
for_ref_opt | A proof that any option wrapped reference has same layout as an pure reference. |
for_sized_ptr | A proof that sized pointers have same layout as any other sized pointer. |
id | A proof that any type has the same layout as itself. |