From 467502216efabae9e209b30702fc9444b184de7a Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Thu, 28 Mar 2013 17:53:29 -0400 Subject: [PATCH 1/2] tutorial: cleaner libc use statements --- doc/tutorial.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/doc/tutorial.md b/doc/tutorial.md index 6932cf7e47ffd..405d70678fe95 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -875,8 +875,7 @@ the compiler that unsafety does not leak outside of the unsafe block, and is used to create safe concepts on top of low-level code. ~~~~ -use core::libc::funcs::c95::stdlib::{calloc, free}; -use core::libc::types::os::arch::c95::size_t; +use core::libc::{calloc, free, size_t}; fn main() { unsafe { @@ -909,9 +908,7 @@ The unsafe code from above can be contained behind a safe API that prevents memory leaks or use-after-free: ~~~~ -use core::libc::funcs::c95::stdlib::{calloc, free}; -use core::libc::types::common::c95::c_void; -use core::libc::types::os::arch::c95::size_t; +use core::libc::{calloc, free, c_void, size_t}; struct Blob { priv ptr: *c_void } From d4509f270b57d6a8869cf45ef29f2e0313592c52 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Thu, 28 Mar 2013 18:40:44 -0400 Subject: [PATCH 2/2] tutorial: only Owned types can have a Drop impl --- doc/tutorial.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/tutorial.md b/doc/tutorial.md index 405d70678fe95..9f36786648aba 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -982,7 +982,9 @@ when it is collected. If an object doesn't contain garbage-collected boxes, it consists of a single ownership tree and is given the `Owned` trait which allows it to be sent -between tasks. +between tasks. Custom destructors can only be implemented directly on types +that are `Owned`, but garbage-collected boxes can still *contain* types with +custom destructors. # Boxes