std::mem - Rust
Description: API documentation for the Rust `mem` mod in crate `std`.
Keywords: rust, rustlang, rust-lang, mem

# 1.0.0[−][src]Module std::mem

Basic functions for dealing with memory.

This module contains functions for querying the size and alignment of types, initializing and manipulating memory.

## Structs

Discriminant | Opaque type representing the discriminant of an enum.
ManuallyDrop | A wrapper to inhibit compiler from automatically calling `T`’s destructor.

## Functions

align_of | Returns the ABI-required minimum alignment of a type.
align_of_val | Returns the ABI-required minimum alignment of the type of the value that `val` points to.
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_of | Deprecated Returns the ABI-required minimum alignment of a type.
min_align_of_val | Deprecated Returns the ABI-required minimum alignment of the type of the value that `val` points to.
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.
swap | Swaps the values at two mutable locations, without deinitializing either one.
transmute⚠ | Reinterprets the bits of a value of one type as another type.
transmute_copy⚠ | Interprets `src` as having type `&U`, and then reads `src` without moving the contained value.
uninitialized⚠ | Deprecation planned Bypasses Rust's normal memory-initialization checks by pretending to produce a value of type `T`, while doing nothing at all.
zeroed⚠ | Creates a value whose bytes are all zero.
forget_unsized | Experimental Like `forget`, but also accepts unsized values.

## Unions

MaybeUninit | Experimental A wrapper to construct uninitialized instances of `T`.

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g., `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g., `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)