Expand description
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§
- Same
Layout - A proof type, showing two types
A
andB
have the same layout.
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.