Skip to content

Unsafe practice problems in Rust

Difficulty:
Category:
Tag:

Showing 37 of 37

Status Title Difficulty
A macro-generated FFI binding layer Hard
Bounds checks: when they cost, and five safe ways to remove them Hard
Build a spinlock from AtomicBool and UnsafeCell Hard
Build `Cell<T>` and `RefCell<T>` from scratch Hard
Build Rc<T> and RefCell<T> from scratch Hard
Calling C from Rust: libc is already linked Medium
Capstone: audit and repair an unsound abstraction Hard
C strings, ownership across the boundary, and FFI-safe types Medium
Designing safe wrappers around unsafe FFI Hard
Edition 2024: unsafe extern blocks and safe declarations Medium
Edition 2024: #[unsafe(no_mangle)] and calling Rust from C in one file Hard
Implementing a reference-counted pointer Hard
Implementing `Vec`: layout, allocation, push, pop Hard
Implementing `Vec` part 2: `insert`, `remove`, `Deref`, `IntoIter` Hard
Leaking is safe, and exception safety Hard
`NonNull<T>`, null, and dangling-but-aligned Medium
Nullable pointer optimization, callbacks and qsort Hard
Opaque pointers, variadics, and the FFI hazard catalogue Hard
Partial initialisation and leak-free unwinding: a `MaybeUninit` ring buffer Hard
`PhantomData`, variance and drop-check Hard
Pointer arithmetic: `offset`, `add`, `sub`, `wrapping_*` Medium
Provenance: a pointer is not an integer Hard
`ptr::read`, `write`, `copy`, `copy_nonoverlapping`, `drop_in_place` Medium
`&raw const` / `&raw mut`: a pointer without a reference Medium
Raw pointers: `*const T` and `*mut T` Easy
`RawWaker` and `RawWakerVTable`: building a `Waker` with unsafe Hard
Safety comments as a discipline: `// SAFETY:` and `# Safety` Easy
Splitting borrows: implement `split_at_mut` Medium
`static mut` is dead: what edition 2024 changed Medium
Structural pinning and safe pin projection by hand Hard
The five superpowers — and the four myths Easy
`union`, `transmute` and `MaybeUninit` Hard
`UnsafeCell`: the only legal path to interior mutability Medium
unsafe impl Send, and the disjoint-capture trap Hard
`unsafe {}` vs `unsafe fn`: edition 2024 splits the two meanings Easy
Unsound API smells: the patterns that are always wrong Medium
Validity invariants vs safety invariants Medium