[−][src]Crate alloc
A shim crate for to import items of alloc crate ergonomically.
Usage
Add this to your Cargo.toml:
[dependencies]
alloc-shim = "0.3.0"
Set the features so that std depends on alloc-shim/std, and alloc depends on alloc-shim/alloc:
[features]
std = ["alloc-shim/std"]
alloc = ["alloc-shim/alloc"]
Add this to your crate root (lib.rs or main.rs):
#![cfg_attr(feature = "alloc", feature(alloc))]Now, you can use alloc-shim:
#[cfg(any(feature = "alloc", feature = "std"))] use alloc::prelude::*; // And more...
The current version of alloc-shim requires Rust 1.31 or later.
Crate Features
If not either std or alloc is specified, this crate does nothing.
-
std- Disabled by default.
- Enable to use
stdcrate.
-
alloc- Disabled by default.
- Enable to use
alloccrate. - Note that
stdcrate is used if bothstdandallocare specified at the same time. - This requires Rust Nightly.
-
futures- Disabled by default.
- Enable to use
alloc::task. - This requires Rust Nightly.
Modules
| alloc | Memory allocation APIs |
| borrow | A module for working with borrowed data. |
| boxed | A pointer type for heap allocation. |
| collections | Collection types. |
| fmt | Utilities for formatting and printing |
| rc | Single-threaded reference-counting pointers. 'Rc' stands for 'Reference Counted'. |
| slice | A dynamically-sized view into a contiguous sequence, |
| str | Unicode string slices. |
| string | A UTF-8 encoded, growable string. |
| vec | A contiguous growable array type with heap-allocated contents, written
|
| prelude | [ Experimental ] The alloc Prelude |
| sync | Synchronization primitives |
Macros
| format | Creates a |
| vec | Creates a |