Step Into Rust · Lesson 10 · Systems Rust
Unsafe & Raw Pointers
What unsafe allows, *const and *mut, pointer arithmetic, byte views and repr(C).
- ~35 minreading and coding
- 4missions
- membersaccess
- Rustlanguage
Part of Step Into Rust. The full lesson, its missions and the real compiler and debugger are in the course. Try a free lesson first to see how it works.
Safe Rust can't express everything: talking to hardware, calling C, or reading a structure the OS hands you as a raw address. unsafe unlocks a few extra powers, and you promise the compiler that you use them correctly:
In this lesson
- What unsafe is for
- Raw pointers
- Viewing memory as bytes
- Layout: repr(C)
Missions
- Write through a raw pointer
- Pointer arithmetic
- See the bytes
- Match the C layout