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.

Modules§

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§

Discriminantvalidated
Opaque type representing the discriminant of an enum.
ManuallyDropvalidated
A wrapper to inhibit the compiler from automatically calling T’s destructor. This wrapper is 0-cost.
AlignmentExperimentalvalidated
A type storing a usize which is a power of two, and thus represents a possible alignment in the Rust abstract machine.
AssumeExperimental
Configurable proof assumptions of TransmuteFrom.
DropGuardExperimental
Wrap a value and run a closure when dropped.
MaybeDanglingExperimentalvalidated
Allows wrapped references and boxes to dangle.

Traits§

TransmuteFromExperimental
Marks that Src is transmutable into Self.

Functions§

align_ofvalidated
Returns the ABI-required minimum alignment of a type in bytes.
align_of_valvalidated
Returns the ABI-required minimum alignment of the type of the value that val points to in bytes.
discriminantvalidated
Returns a value uniquely identifying the enum variant in v.
dropvalidated
Disposes of a value.
forgetvalidated
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_dropvalidated
Returns true if dropping values of type T matters.
replacevalidated
Moves src into the referenced dest, returning the previous dest value.
size_ofvalidated
Returns the size of a type in bytes.
size_of_valvalidated
Returns the size of the pointed-to value in bytes.
swapvalidated
Swaps the values at two mutable locations, without deinitializing either one.
takevalidated
Replaces dest with the default value of T, returning the previous dest value.
transmutevalidated
Reinterprets the bits of a value of one type as another type.
transmute_copyvalidated
Interprets src as having type &Dst, and then reads src without moving the contained value.
uninitializedDeprecated
Bypasses Rust’s normal memory-initialization checks by pretending to produce a value of type T, while doing nothing at all.
zeroedvalidated
Returns the value of type T represented by the all-zero byte-pattern.
align_of_val_rawExperimental
Returns the ABI-required minimum alignment of the type of the value that val points to in bytes.
conjure_zstExperimentalvalidated
Create a fresh instance of the inhabited ZST type T.
copyExperimental
Bitwise-copies a value.
forget_unsizedExperimental
Like forget, but also accepts unsized values.
size_of_val_rawExperimentalvalidated
Returns the size of the pointed-to value in bytes.
variant_countExperimental
Returns the number of variants in the enum type T.

Unions§

MaybeUninit
A wrapper type to construct uninitialized instances of T.