Skip to content

Commit 73df19a

Browse files
committed
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
1 parent 26f0cd5 commit 73df19a

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/doc/trpl/unsafe.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ this, Rust has a keyword, `unsafe`. Code using `unsafe` has less restrictions
88
than normal code does.
99

1010
Let’s go over the syntax, and then we’ll talk semantics. `unsafe` is used in
11-
two contexts. The first one is to mark a function as unsafe:
11+
four contexts. The first one is to mark a function as unsafe:
1212

1313
```rust
1414
unsafe fn danger_will_robinson() {
@@ -27,6 +27,19 @@ unsafe {
2727
}
2828
```
2929

30+
The third is for unsafe traits:
31+
32+
```rust
33+
unsafe trait Scary { }
34+
```
35+
36+
And the fourth is for `impl`ementing one of those traits:
37+
38+
```rust
39+
# unsafe trait Scary { }
40+
unsafe impl Scary for i32 {}
41+
```
42+
3043
It’s important to be able to explicitly delineate code that may have bugs that
3144
cause big problems. If a Rust program segfaults, you can be sure it’s somewhere
3245
in the sections marked `unsafe`.

0 commit comments

Comments
 (0)