
Memory allocation and lifetime - The Rust Reference
The items of a program are those functions, modules, and types that have their value calculated at compile-time and stored uniquely in the memory image of the rust process.
std::mem - Rust
Feb 11, 2026 · Basic functions for dealing with memory. This module contains functions for querying the size and alignment of types, initializing and manipulating memory.
What is Ownership? - The Rust Programming Language
Rust uses a third approach: Memory is managed through a system of ownership with a set of rules that the compiler checks. If any of the rules are violated, the program won’t compile.
Understanding Ownership - The Rust Programming Language
It enables Rust to make memory safety guarantees without needing a garbage collector, so it’s important to understand how ownership works. In this chapter, we’ll talk about ownership as well as several …
Memory model - The Rust Reference
While bytes are typically lowered to hardware bytes, Rust uses an “abstract” notion of bytes that can make distinctions which are absent in hardware, such as being uninitialized, or storing part of a pointer.
Type layout - The Rust Reference
There are crucial differences between an enum in the C language and Rust’s field-less enums with this representation. An enum in C is mostly a typedef plus some named constants; in other words, an …
Leaking - The Rustonomicon - Learn Rust
Many people like to believe that Rust eliminates resource leaks. In practice, this is basically true. You would be surprised to see a Safe Rust program leak resources in an uncontrolled way. However from …
forget in std::mem - Rust
Feb 11, 2026 · That said, leaking resources such as memory or I/O objects is usually undesirable. The need comes up in some specialized use cases for FFI or unsafe code, but even then, ManuallyDrop …
Allocator in std::alloc - Rust
Feb 11, 2026 · Returning Err indicates that either memory is exhausted or layout does not meet allocator’s size or alignment constraints. Implementations are encouraged to return Err on memory …
Vec in std::vec - Rust
If a Vec has allocated memory, then the memory it points to is on the heap (as defined by the allocator Rust is configured to use by default), and its pointer points to len initialized, contiguous elements in …