Skip to content

Unsafe practice problems in Rust

Difficulty:
Category & tags Filters active
Category:
Tag:

Showing 37 of 37

Title Difficulty
A macro-generated FFI binding layer Hard
Bounds checks: five safe ways to express access Hard
Build a ring buffer with MaybeUninit Hard
Build a safe mutable-slice split Medium
Build a spinlock from AtomicBool and UnsafeCell Hard
Build a vector with allocation, push and pop Hard
Build Cell<T> and RefCell<T> from scratch Hard
Build Rc<T> and RefCell<T> from scratch Hard
Calling C functions through safe Rust wrappers Medium
Capstone: audit and repair an unsound abstraction Hard
C strings and ownership across FFI Medium
Designing safe wrappers around unsafe FFI Hard
Edition 2024: unsafe extern blocks and safe declarations Medium
Export Rust functions with C-compatible names and signatures Hard
Extend a vector with insertion and consuming iteration Hard
Implementing a reference-counted pointer Hard
Keep a vector valid when its drain is forgotten Hard
NonNull<T>, null, and dangling-but-aligned Medium
Nullable pointer optimization, callbacks and qsort Hard
Opaque handles and bounded C formatting 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
static mut is dead: what edition 2024 changed Medium
Structural pinning and safe pin projection by hand Hard
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: two fixes and a review checklist Medium
Validity invariants vs safety invariants Medium
What unsafe allows, and what it does not change Easy