diff options
| author | Simon Sapin <simon.sapin@exyr.org> | 2018-04-03 17:12:57 +0200 |
|---|---|---|
| committer | Simon Sapin <simon.sapin@exyr.org> | 2018-04-12 22:53:12 +0200 |
| commit | 86753ce1cc520bfe50ae89f09ec47f313ce900eb (patch) | |
| tree | 5611452336d4e8dbf10c2f21b9516d46743092f8 /src/doc | |
| parent | eb69593f73be1e41d9e2ef065010a47478c14924 (diff) | |
| download | rust-86753ce1cc520bfe50ae89f09ec47f313ce900eb.tar.gz rust-86753ce1cc520bfe50ae89f09ec47f313ce900eb.zip | |
Use the GlobalAlloc trait for #[global_allocator]
Diffstat (limited to 'src/doc')
| -rw-r--r-- | src/doc/unstable-book/src/language-features/global-allocator.md | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/doc/unstable-book/src/language-features/global-allocator.md b/src/doc/unstable-book/src/language-features/global-allocator.md index b3e6925b666..6ce12ba684d 100644 --- a/src/doc/unstable-book/src/language-features/global-allocator.md +++ b/src/doc/unstable-book/src/language-features/global-allocator.md @@ -29,16 +29,16 @@ looks like: ```rust #![feature(global_allocator, allocator_api, heap_api)] -use std::heap::{Alloc, System, Layout, AllocErr}; +use std::alloc::{GlobalAlloc, System, Layout, Void}; struct MyAllocator; -unsafe impl<'a> Alloc for &'a MyAllocator { - unsafe fn alloc(&mut self, layout: Layout) -> Result<*mut u8, AllocErr> { +unsafe impl GlobalAlloc for MyAllocator { + unsafe fn alloc(&self, layout: Layout) -> *mut Void { System.alloc(layout) } - unsafe fn dealloc(&mut self, ptr: *mut u8, layout: Layout) { + unsafe fn dealloc(&self, ptr: *mut Void, layout: Layout) { System.dealloc(ptr, layout) } } |
