Skip to main content

Module mem

Module mem 

1.6.0 · Source
Expand description

Basic functions for dealing with memory, values, and types.

The contents of this module can be seen as belonging to a few families:

See also the alloc and ptr modules for more primitive operations on memory.

Re-exports§

pub use manually_drop::ManuallyDrop;
pub use maybe_uninit::MaybeUninit;
pub use drop_guard::DropGuard;
pub use alignment::Alignment;Experimental
pub use maybe_dangling::MaybeDangling;Experimental
pub use transmutability::Assume;Experimental
pub use transmutability::TransmuteFrom;Experimental

Modules§

alignment 🔒
drop_guard 🔒
manually_drop 🔒
maybe_uninit 🔒
transmutability 🔒
maybe_dangling 🔒 Experimental
type_infoExperimental
MVP for exposing compile-time information about types in a runtime or const-eval processable way.

Macros§

offset_of
Expands to the offset in bytes of a field from the beginning of the given type.

Structs§

Discriminant
Opaque type representing the discriminant of an enum.

Traits§

SizedTypeProperties 👻 Experimental
Provides associated constants for various useful properties of types, to give them a canonical form in our code and make them easier to read.

Functions§

align_of
Returns the ABI-required minimum alignment of a type, in bytes.
align_of_val
Returns the ABI-required minimum alignment of the type of the value that val points to, in bytes.
align_of_val_raw⚠
Returns the ABI-required minimum alignment of the type of the value that val points to, in bytes.
conjure_zst⚠
Create a fresh instance of the inhabited ZST type T.
discriminant
Returns a value uniquely identifying the enum variant in v.
drop
Disposes of a value.
forget
Takes ownership and “forgets” about the value without running its destructor.
min_align_ofDeprecated
Returns the ABI-required minimum alignment of a type in bytes.
min_align_of_valDeprecated
Returns the ABI-required minimum alignment of the type of the value that val points to in bytes.
needs_drop
Returns true if dropping values of type T matters.
replace
Moves src into the referenced dest, returning the previous dest value.
size_of
Returns the size of a type in bytes.
size_of_val
Returns the size of the pointed-to value in bytes.
size_of_val_raw⚠
Returns the size of the pointed-to value in bytes.
swap
Swaps the values at two mutable locations, without deinitializing either one.
take
Replaces dest with the default value of T, returning the previous dest value.
transmute⚠
Reinterprets the bits of a value of one type as another type.
transmute_copy⚠
Interprets src as having type &Dst, and then reads src without moving the contained value.
uninitialized⚠Deprecated
Bypasses Rust’s normal memory-initialization checks by pretending to produce a value of type T, while doing nothing at all.
zeroed⚠
Returns the value of type T represented by the all-zero byte-pattern.
copyExperimental
Bitwise-copies a value.
forget_unsizedExperimental
Like forget, but also accepts unsized values.
transmute_neo⚠Experimental
New version of transmute, exposed under this name so it can be iterated upon without risking breakage to uses of “real” transmute.
transmute_prefix⚠Experimental
Like transmute, but only initializes the “common prefix” of the first min(size_of::<Src>(), size_of::<Dst>()) bytes of the destination from the corresponding bytes of the source.
variant_countExperimental
Returns the number of variants in the enum type T.