1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-03-21 22:49:44 +02:00

Merge pull request #94 from MaschitaG/patch-2

Unsafe Rust
This commit is contained in:
Martin Geisler 2023-01-02 10:32:00 +01:00 committed by GitHub
commit 2a92487bbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 7 deletions

View File

@ -36,4 +36,4 @@ fn main() {
} }
``` ```
We will look at mutating static data in the chapter on Unsafe Rust. We will look at mutating static data in the [chapter on Unsafe Rust](../unsafe.md).

View File

@ -6,13 +6,16 @@ The Rust language has two parts:
* **Unsafe Rust:** can trigger undefined behavior if preconditions are violated. * **Unsafe Rust:** can trigger undefined behavior if preconditions are violated.
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 Rust gives you access to five new capabilities: Unsafe Rust gives you access to five new capabilities:
* Dereference raw pointers. * Dereference raw pointers.
* Access or modify mutable static variables. * Access or modify mutable static variables.
* Access `union` fields. * Access `union` fields.
* 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
[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/).

View File

@ -33,10 +33,6 @@ Some non-goals of this course are:
* Learn how to develop macros, please see [Chapter 19.5 in the Rust * Learn how to develop macros, please see [Chapter 19.5 in the Rust
Book](https://doc.rust-lang.org/book/ch19-06-macros.html) and [Rust by Book](https://doc.rust-lang.org/book/ch19-06-macros.html) and [Rust by
Example](https://doc.rust-lang.org/rust-by-example/macros.html) instead. Example](https://doc.rust-lang.org/rust-by-example/macros.html) instead.
* Learn the details of how to write unsafe Rust. We will talk about unsafe Rust
on Day 3, but we do not cover the subtle details. Please see [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/) instead.
## Assumptions ## Assumptions