Skip to content

tutorial: cleaner libc use statements + mention Drop's Owned restriction #5610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 }

Expand Down Expand Up @@ -985,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

Expand Down