Step Into Labs

Step Into Rust · Lesson 10 · Systems Rust

Unsafe & Raw Pointers

What unsafe allows, *const and *mut, pointer arithmetic, byte views and repr(C).

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

Missions

  1. Write through a raw pointer
  2. Pointer arithmetic
  3. See the bytes
  4. Match the C layout