Master the fundamental concepts of rust for systems programming through this focused micro-challenge.
Industrial C-to-Rust ports (Fish shell, Android components, DARPA TRACTOR research) succeed when idioms map cleanly. You are not transliterating syntax; you are replacing manual memory with ownership and errno checks with Result.
| C habit | Rust idiom |
|---|---|
malloc/free | Box, Vec, owned buffers |
char* | &str, String, CStr at FFI edges |
| NULL pointers | Option<T> |
union | enum with variants |
for (i=0; ...) | iterators |
cLoading…
rustLoading…
Start porting with behavior parity tests, then tighten types. Keep unsafe at FFI boundaries only.
For this exercise, you will port a small C utility to Rust and compare output and runtime. This task asks you to document each pattern swap, because migration reviews fail when teams copy pointers verbatim into *mut u8 without a safety story.
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. Skim the official documentation for the tool or ABI named in the exercise; the prose changes, but register roles, syscall numbers, and ownership rules stay stable across releases.
Port a simple C program to Rust and benchmark both.
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