diff options
| author | Steve Klabnik <steve@steveklabnik.com> | 2015-07-07 09:26:23 -0400 |
|---|---|---|
| committer | Steve Klabnik <steve@steveklabnik.com> | 2015-07-07 09:26:23 -0400 |
| commit | 73df19a206f731a24b0ff7a5e701fa1d337211cd (patch) | |
| tree | ab89b78b4f3082c3ba68d5e05a97ae6bf0c2618a | |
| parent | 26f0cd5de7f71a0db0bb3857ce49a11cd0f7d876 (diff) | |
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
| -rw-r--r-- | src/doc/trpl/unsafe.md | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/doc/trpl/unsafe.md b/src/doc/trpl/unsafe.md index e8f1b829061..2f92f50bb22 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`. |
