diff options
Diffstat (limited to 'src/doc/guide-unsafe.md')
| -rw-r--r-- | src/doc/guide-unsafe.md | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/doc/guide-unsafe.md b/src/doc/guide-unsafe.md index 11bc0bc30f2..25ca07ad74f 100644 --- a/src/doc/guide-unsafe.md +++ b/src/doc/guide-unsafe.md @@ -197,6 +197,7 @@ extern crate libc; use libc::{c_void, size_t, malloc, free}; use std::mem; use std::ptr; +# use std::boxed::Box; // Define a wrapper around the handle returned by the foreign code. // Unique<T> has the same semantics as Box<T> @@ -265,7 +266,7 @@ impl<T: Send> Drop for Unique<T> { // A comparison between the built-in `Box` and this reimplementation fn main() { { - let mut x = box 5i; + let mut x = Box::new(5i); *x = 10; } // `x` is freed here @@ -653,7 +654,7 @@ sugar for dynamic allocations via `malloc` and `free`: ``` #![no_std] -#![feature(lang_items)] +#![feature(lang_items, box_syntax)] extern crate libc; |
