RUST Essentials Intermediate

Linked List with Raw Pointers in Rust

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

Premium · 4h 34m · 4 ch
Practice →
Linked List with Raw Pointers in Rust cover

What you'll build

We will build a complete doubly linked list from scratch in Rust, starting with a simple singly linked stack and gradually evolving it into a fully functional doubly linked list with raw pointers and unsafe code. Along the way, we will implement three types of iterators (shared, mutable, and owning), transition from safe Box-based pointers to raw NonNull pointers, add panic-safe deallocation logic, and support bidirectional traversal — thoroughly exploring Rust's ownership model, lifetime system, and unsafe abstractions.

Learning objectives

✓Understand how linked lists work at the pointer level
✓Use Rust generics and type aliases to model recursive data structures
✓Implement insertion and removal operations for a singly linked stack
✓Build shared, mutable, and owning iterators with correct lifetime annotations
✓Transition from safe Box pointers to raw NonNull pointers
✓Write a panic-safe Drop implementation using a deallocation guard
✓Extend a singly linked list into a doubly linked list with a 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
—Adding the Node Structure
—Adding the Linked List Structure
—Adding Methods
—Element Addition Method
—Element removal method
—Implementing Traits
—Creating a Minimal Test
2 Non-consuming iterator
—Implementing a Non-Consuming Iterator
—Testing the Non-Consuming Iterator
3 Consuming Iterator
—Implementing 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.