take, swap, replace

`mem::take` replaces a `&mut T` with `T::default()` and returns the original. `mem::swap` swaps two `&mut T` in place. `mem::replace` swaps a `&mut T` with a new value and returns the old. These three functions are how you move out of a place referenced by `&mut` without violating the borrow checker — perfect for self-mutating state machines and copy-free updates.

size_of and align_of

`mem::size_of::<T>()` returns the size of T in bytes; `mem::align_of::<T>()` returns the alignment requirement. Use them when interfacing with FFI, when packing data into byte buffers, or when reasoning about cache lines. There is also `mem::size_of_val(&val)` for unsized types like trait objects whose size depends on the runtime type.

For deeper background, see a complete cheat-sheet of std collection complexities for the broader context behind this section.

drop

`mem::drop(value)` is just `pub fn drop<T>(_: T) {}` — it consumes a value, ending its lifetime early. Useful for releasing a Mutex guard or RAII resource before the natural end of the scope. Despite the name, dropping is not unsafe — the destructor still runs.

ManuallyDrop, MaybeUninit, transmute

These are the tools of last resort. `ManuallyDrop<T>` opts out of automatic Drop, leaving you to call `drop_in_place` yourself. `MaybeUninit<T>` lets you work with potentially-uninitialised memory in a safe wrapper. `transmute` reinterprets bytes from one type to another and is almost always wrong outside FFI shims and intrinsics. Reach for them only when you understand the language's memory model in depth.

For deeper background, see the official Rust API guidelines for module-level design for the broader context behind this section.

Layout-related: zeroed, uninitialized

`mem::zeroed` and `mem::uninitialized` produce a value of any type as if its bytes were all-zero or undefined. Both are unsafe and `uninitialized` has been deprecated in favour of `MaybeUninit`. Use them only with types where every bit pattern is valid (integers, raw pointers, plain old data).