Crate alloc [−] [src]
: this library is unlikely to be stabilized in its current form or name
The Rust core allocation library
This is the lowest level library through which allocation in Rust can be performed.
This library, like libcore, is not intended for general usage, but rather as a building block of other libraries. The types and interfaces in this library are reexported through the standard library, and should not be used through this library.
Currently, there are four major definitions in this library.
Boxed values
The Box
`Box` type is a smart pointer type. There can
only be one owner of a Box
`Box`, and the owner can decide to mutate the
contents, which live on the heap.
This type can be sent among threads efficiently as the size of a Box
`Box` value
is the same as that of a pointer. Tree-like data structures are often built
with boxes because each node often has only one owner, the parent.
Reference counted pointers
The Rc
`Rc` type is a non-threadsafe reference-counted pointer
type intended for sharing memory within a thread. An Rc
`Rcpointer wraps a type,
T, and only allows access to
&T`, a shared reference.
This type is useful when inherited mutability (such as using Box
`Box) is too constraining for an application, and is often paired with the
Cellor
` or
RefCell
`RefCell` types in order to allow mutation.
Atomically reference counted pointers
The Arc
`Arc` type is the threadsafe equivalent of the Rc
`Rctype. It provides all the same functionality of
Rc, except it requires that the contained type
Tis shareable. Additionally,
Arcis itself sendable while
Rc
This types allows for shared access to the contained data, and is often paired with synchronization primitives such as mutexes to allow mutation of shared resources.
Heap interfaces
The heap
`heap` module defines the low-level interface to the
default global allocator. It is not compatible with the libc allocator API.
Modules
arc |
Threadsafe reference-counted boxes (the |
boxed |
A pointer type for heap allocation. |
rc |
Thread-local reference-counted boxes (the |
heap | [Unstable] |
raw_vec | [Unstable] |
Functions
oom |
[Unstable] Common out-of-memory routine |