Master the fundamental concepts of rust for systems programming through this focused micro-challenge.
Safe Rust proves memory and thread safety at compile time. unsafe is an explicit escape hatch for operations the compiler cannot verify: dereferencing raw pointers, calling FFI, touching static mut, or implementing unsafe traits like Send manually.
rustLoading…
unsafe block should be the smallest possible scope with a comment stating the invariant you upholdFFI to C, intrusive data structures, device MMIO, and hot paths that need from_utf8_unchecked-style promises. The standard library uses unsafe internally so your safe APIs stay fast.
For this exercise, you will manipulate raw pointers and call an unsafe fn behind a safe wrapper. This task asks you to document the safety contract your wrapper enforces, because "just slap unsafe on it" is how Rust projects recreate C bugs with extra steps.
Keep the relevant man page, ABI doc, or Rust reference chapter open while you work. When your output disagrees with the reference implementation on the same machine, the mismatch is usually an alignment rule, an off-by-one terminator, or a register slot you misread in GDB.
Use unsafe Rust to work with raw pointers and FFI.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github