|
|
@ -28,7 +28,7 @@ For instance, a custom implementation of `Box` might write `Drop` like this:
|
|
|
|
```rust
|
|
|
|
```rust
|
|
|
|
#![feature(ptr_internals, allocator_api)]
|
|
|
|
#![feature(ptr_internals, allocator_api)]
|
|
|
|
|
|
|
|
|
|
|
|
use std::alloc::{Alloc, Global, GlobalAlloc, Layout};
|
|
|
|
use std::alloc::{AllocRef, Global, GlobalAlloc, Layout};
|
|
|
|
use std::mem;
|
|
|
|
use std::mem;
|
|
|
|
use std::ptr::{drop_in_place, NonNull, Unique};
|
|
|
|
use std::ptr::{drop_in_place, NonNull, Unique};
|
|
|
|
|
|
|
|
|
|
|
@ -55,7 +55,7 @@ However this wouldn't work:
|
|
|
|
```rust
|
|
|
|
```rust
|
|
|
|
#![feature(allocator_api, ptr_internals)]
|
|
|
|
#![feature(allocator_api, ptr_internals)]
|
|
|
|
|
|
|
|
|
|
|
|
use std::alloc::{Alloc, Global, GlobalAlloc, Layout};
|
|
|
|
use std::alloc::{AllocRef, Global, GlobalAlloc, Layout};
|
|
|
|
use std::ptr::{drop_in_place, Unique, NonNull};
|
|
|
|
use std::ptr::{drop_in_place, Unique, NonNull};
|
|
|
|
use std::mem;
|
|
|
|
use std::mem;
|
|
|
|
|
|
|
|
|
|
|
@ -128,7 +128,7 @@ of Self during `drop` is to use an Option:
|
|
|
|
```rust
|
|
|
|
```rust
|
|
|
|
#![feature(allocator_api, ptr_internals)]
|
|
|
|
#![feature(allocator_api, ptr_internals)]
|
|
|
|
|
|
|
|
|
|
|
|
use std::alloc::{Alloc, GlobalAlloc, Global, Layout};
|
|
|
|
use std::alloc::{AllocRef, GlobalAlloc, Global, Layout};
|
|
|
|
use std::ptr::{drop_in_place, Unique, NonNull};
|
|
|
|
use std::ptr::{drop_in_place, Unique, NonNull};
|
|
|
|
use std::mem;
|
|
|
|
use std::mem;
|
|
|
|
|
|
|
|
|
|
|
|