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
This commit is contained in:
Steve Klabnik 2015-07-07 09:26:23 -04:00
parent 26f0cd5de7
commit 73df19a206

View File

@ -8,7 +8,7 @@ this, Rust has a keyword, `unsafe`. Code using `unsafe` has less restrictions
than normal code does.
Lets go over the syntax, and then well 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 {}
```
Its 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 its somewhere
in the sections marked `unsafe`.