mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-04-26 17:23:01 +02:00
Update unsafe.md (#252)
* Update unsafe.md Adding a paragraph explaining that unsafe code is not necessary broken or evil, but it is a mode where compiler safety features are off. * Move explanation to speaker notes To avoid slide being too long. Also edited text slightly. * Remove extra space --------- Co-authored-by: Andrew Walbran <qwandor@google.com>
This commit is contained in:
parent
efa593e020
commit
100ee591ed
@ -8,6 +8,9 @@ The Rust language has two parts:
|
|||||||
We will be seeing mostly safe Rust in this course, but it's important to know
|
We will be seeing mostly safe Rust in this course, but it's important to know
|
||||||
what Unsafe Rust is.
|
what Unsafe Rust is.
|
||||||
|
|
||||||
|
Unsafe code is usually small and isolated, and its correctness should be carefully
|
||||||
|
documented. It is usually wrapped in a safe abstraction layer.
|
||||||
|
|
||||||
Unsafe Rust gives you access to five new capabilities:
|
Unsafe Rust gives you access to five new capabilities:
|
||||||
|
|
||||||
* Dereference raw pointers.
|
* Dereference raw pointers.
|
||||||
@ -16,6 +19,14 @@ Unsafe Rust gives you access to five new capabilities:
|
|||||||
* Call `unsafe` functions, including `extern` functions.
|
* Call `unsafe` functions, including `extern` functions.
|
||||||
* Implement `unsafe` traits.
|
* Implement `unsafe` traits.
|
||||||
|
|
||||||
We will briefly cover these capabilities next. For full details, please see
|
We will briefly cover unsafe capabilities next. For full details, please see
|
||||||
[Chapter 19.1 in the Rust Book](https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html)
|
[Chapter 19.1 in the Rust Book](https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html)
|
||||||
and the [Rustonomicon](https://doc.rust-lang.org/nomicon/).
|
and the [Rustonomicon](https://doc.rust-lang.org/nomicon/).
|
||||||
|
|
||||||
|
<details>
|
||||||
|
|
||||||
|
Unsafe Rust does not mean the code is incorrect. It means that developers have
|
||||||
|
turned off the compiler safety features and have to write correct code by
|
||||||
|
themselves. It means the compiler no longer enforces Rust's memory-safety rules.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user