Welcome to Unsafe Rust
IMPORTANT: THIS MODULE IS IN AN EARLY STAGE OF DEVELOPMENT
Please do not consider this module of Comprehensive Rust to be complete. With that in mind, your feedback, comments, and especially your concerns, are very welcome.
To comment on this module’s development, please use the GitHub issue tracker.
The unsafe
keyword is easy to type, but hard to master. When used appropriately, it forms a useful and indeed essential part of the Rust programming language.
By the end of this deep dive, you’ll know how to work with unsafe
code, review others’ changes that include the unsafe
keyword, and produce your own.
What you’ll learn:
- What the terms undefined behavior, soundness, and safety mean
- Why the
unsafe
keyword exists in the Rust language - How to write your own code using
unsafe
safely - How to review
unsafe
code
Links to other sections of the course
The unsafe
keyword has treatment in:
- Rust Fundamentals, the main module of Comprehensive Rust, includes a session on Unsafe Rust in its last day.
- Rust in Chromium discusses how to interoperate with C++. Consult that material if you are looking into FFI.
- Bare Metal Rust uses unsafe heavily to interact with the underlying host, among other things.