RUST Data Structures Intermediate

Raw Linked List in Rust

Create a linked list from scratch with unsafe memory, raw pointers, and custom drop guards.

Premium · 4h 40m · 4 ch
Practice →
Raw Linked List in Rust cover

What you'll build

We'll build a complete doubly-linked list from scratch in Rust, starting with a simple singly-linked stack and progressively evolving it into a full-featured doubly-linked list with raw pointers and unsafe code. Along the way we'll implement three iterator types (shared, mutable, and owning), convert from safe Box-based pointers to raw NonNull pointers, add panic-safe drop logic, and support bidirectional traversal — exploring Rust's ownership model, lifetime system, and unsafe abstractions in depth.

Learning objectives

Understand how linked lists work at the pointer level
Use Rust generics and type aliases to model recursive data structures
Implement push and pop operations for a singly-linked stack
Build shared, mutable, and owning iterators with proper lifetime annotations
Transition from safe Box pointers to raw NonNull pointers
Write a panic-safe Drop implementation using a drop guard
Extend a singly-linked list into a doubly-linked list with tail pointer
Implement DoubleEndedIterator for bidirectional traversal

Prerequisites

Basic Rust syntax (structs, enums, generics)
Understanding of ownership and borrowing
Familiarity with Option and pattern matching

Course curriculum

1 Linked List
Creating a new crate
Declaration of data types
Adding methods
Implementation of traits
Creating a minimal test
2 Non-consuming iterator
Implementation of a non-consuming iterator
Testing the non-consuming iterator
3 Consuming iterator
Implementation of a consuming iterator
Testing the consuming iterator
4 Doubly Linked List
Refactoring methods
Manual memory management

Technologies

Rust Linked List Data Structures Unsafe Rust Raw Pointers NonNull Iterator DoubleEndedIterator Drop Lifetime PhantomData

FAQ

Is this a video course?

No. You work through the project step by step in your browser, and the reference code for each step saves to your disk — yours to run and keep locally.

Do I need to install anything?

No. The playground runs entirely in your browser — no toolchain or local setup required.

Can I try it before subscribing?

Yes. Preview steps are available without a subscription so you can see the format and quality first.

What do I get with full access?

Every step unlocked, the Workbench app, a snapshot for each step, jump-to-any-step navigation, and all new playground releases.

Does it work with an AI agent like Claude or Codex?

Yes. You can work through a playground solo or alongside an AI agent.

Is there reference code?

Yes. Every step has a complete reference solution you can compare against.

Newsletter

New playgrounds in your inbox

Get an email when a new playground drops, plus the occasional engineering deep-dive. No spam, unsubscribe anytime.