From 73df19a206f731a24b0ff7a5e701fa1d337211cd Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Tue, 7 Jul 2015 09:26:23 -0400 Subject: [PATCH] There are four uses of unsafe, actually I am not mentioning #[unsafe_drop_flag] because it should go away eventually, and also because it's just an attribute, it's not really a use of the `unsafe` keyword. Fixes #26345 --- src/doc/trpl/unsafe.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/doc/trpl/unsafe.md b/src/doc/trpl/unsafe.md index e8f1b829061c2..2f92f50bb228c 100644 --- a/src/doc/trpl/unsafe.md +++ b/src/doc/trpl/unsafe.md @@ -8,7 +8,7 @@ this, Rust has a keyword, `unsafe`. Code using `unsafe` has less restrictions than normal code does. Let’s go over the syntax, and then we’ll talk semantics. `unsafe` is used in -two contexts. The first one is to mark a function as unsafe: +four contexts. The first one is to mark a function as unsafe: ```rust unsafe fn danger_will_robinson() { @@ -27,6 +27,19 @@ unsafe { } ``` +The third is for unsafe traits: + +```rust +unsafe trait Scary { } +``` + +And the fourth is for `impl`ementing one of those traits: + +```rust +# unsafe trait Scary { } +unsafe impl Scary for i32 {} +``` + It’s important to be able to explicitly delineate code that may have bugs that cause big problems. If a Rust program segfaults, you can be sure it’s somewhere in the sections marked `unsafe`.