pull/35/head
Alexis Beingessner 7 years ago
parent 6cbff7eaa6
commit 896d4bdce8

@ -26,7 +26,7 @@ you don't want to drop in a `union`. The standard library provides the
Consider a custom implementation of `Box`, which might write `Drop` like this: Consider a custom implementation of `Box`, which might write `Drop` like this:
```rust ```rust
#![feature(unique, allocator_api)] #![feature(allocator_api)]
use std::heap::{Heap, Alloc, Layout}; use std::heap::{Heap, Alloc, Layout};
use std::mem; use std::mem;
@ -52,7 +52,7 @@ use-after-free the `ptr` because when drop exits, it becomes inaccessible.
However this wouldn't work: However this wouldn't work:
```rust ```rust
#![feature(allocator_api, unique)] #![feature(allocator_api)]
use std::heap::{Heap, Alloc, Layout}; use std::heap::{Heap, Alloc, Layout};
use std::ptr::drop_in_place; use std::ptr::drop_in_place;
@ -124,7 +124,7 @@ The classic safe solution to preventing recursive drop and allowing moving out
of Self during `drop` is to use an Option: of Self during `drop` is to use an Option:
```rust ```rust
#![feature(allocator_api, unique)] #![feature(allocator_api)]
use std::heap::{Alloc, Heap, Layout}; use std::heap::{Alloc, Heap, Layout};
use std::ptr::drop_in_place; use std::ptr::drop_in_place;

@ -292,7 +292,7 @@ fn inspect() {
} }
``` ```
``` ```text
error[E0597]: `*data` does not live long enough error[E0597]: `*data` does not live long enough
--> src/main.rs:37:1 --> src/main.rs:37:1
| |

@ -51,7 +51,7 @@ allocation which is used for multiple arrays of different types:
``` ```
use std::marker; use std::marker;
struct HashMap { struct HashMap<K, V> {
ptr: *mut u8, ptr: *mut u8,
// The pointer actually stores keys and values // The pointer actually stores keys and values
// (and hashes, but those aren't generic) // (and hashes, but those aren't generic)

@ -1,7 +1,7 @@
# The Final Code # The Final Code
```rust ```rust
#![feature(unique)] #![feature(shared)]
#![feature(allocator_api)] #![feature(allocator_api)]
use std::ptr::{Shared, self}; use std::ptr::{Shared, self};

Loading…
Cancel
Save