1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2024-12-02 02:56:26 +02:00

Add more details about alloc.

This commit is contained in:
Andrew Walbran 2023-03-03 18:01:31 +00:00
parent 84cd822080
commit de1be63b82

View File

@ -1,6 +1,7 @@
# `alloc`
To use `alloc` you must implement a global (heap) allocator.
To use `alloc` you must implement a
[global (heap) allocator](https://doc.rust-lang.org/stable/std/alloc/trait.GlobalAlloc.html).
```rust,editable,compile_fail
{{#include alloc-example/src/main.rs:Alloc}}
@ -12,5 +13,7 @@ To use `alloc` you must implement a global (heap) allocator.
crates are available, or you can write your own or hook into your existing allocator.
* The const parameter of `LockedHeap` is the max order of the allocator; i.e. in this case it can
allocate regions of up to 2**32 bytes.
* If any crate in your dependency tree depends on `alloc` then you must have exactly one global
allocator defined in your binary. Usually this is done in the top-level binary crate.
</details>