No description
- Rust 39%
- Zig 36.8%
- C 23.7%
- Makefile 0.5%
| c | ||
| rust | ||
| zig | ||
| .gitignore | ||
| README.md | ||
Doubly Linked List: Rust, C, and Zig
Illustrative implementations of a doubly linked list in three languages, showing how each handles the aliased-mutability problem that makes this data structure famously awkward in Rust.
Rust — unsafe behind a safe API
The Rust version uses raw pointers (*mut Node<T>) inside the
implementation, with every unsafe block annotated with the invariant it
relies on. The public API is fully safe — callers cannot trigger
undefined behavior.
cd rust && cargo run
C — natural habitat
In C, doubly linked lists are straightforward pointer manipulation. No ownership system to negotiate with.
cd c && make && ./ll
Zig — explicit allocators, optional pointers
Zig sits between C and Rust: no borrow checker, but nullable pointer
types (?*T) make null handling explicit at compile time, and debug
builds include runtime safety checks.
cd zig && zig build run