Loading...

Master Rust.

Rust mastery exercises. Become your team's resident Rust expert.

Build your own Redis
FREE THIS MONTH
This challenge is free until 1 December 2024!
Build your own Redis

Discover concurrent programming in Rust while also learning about TCP servers, network programming, and the Redis Protocol.

Bind to a port
Login via GitHub to view this stage
Respond to PING
Login via GitHub to view this stage
Respond to multiple PINGs
Login via GitHub to view this stage
Handle concurrent clients
Login via GitHub to view this stage
Implement the ECHO command
Login via GitHub to view this stage
Implement the SET & GET commands
Login via GitHub to view this stage
Expiry
Login via GitHub to view this stage

RDB Persistence

RDB file config
Login via GitHub to view this stage
Read a key
Login via GitHub to view this stage
Read a string value
Login via GitHub to view this stage
Read multiple keys
Login via GitHub to view this stage
Read multiple string values
Login via GitHub to view this stage
Read value with expiry
Login via GitHub to view this stage

Replication

Configure listening port
Login via GitHub to view this stage
The INFO command
Login via GitHub to view this stage
The INFO command on a replica
Login via GitHub to view this stage
Initial Replication ID and Offset
Login via GitHub to view this stage
Send handshake (1/3)
Login via GitHub to view this stage
Send handshake (2/3)
Login via GitHub to view this stage
Send handshake (3/3)
Login via GitHub to view this stage
Receive handshake (1/2)
Login via GitHub to view this stage
Receive handshake (2/2)
Login via GitHub to view this stage
Empty RDB Transfer
Login via GitHub to view this stage
Single-replica propagation
Login via GitHub to view this stage
Multi Replica Command Propagation
Login via GitHub to view this stage
Command Processing
Login via GitHub to view this stage
ACKs with no commands
Login via GitHub to view this stage
ACKs with commands
Login via GitHub to view this stage
WAIT with no replicas
Login via GitHub to view this stage
WAIT with no commands
Login via GitHub to view this stage
WAIT with multiple commands
Login via GitHub to view this stage

Streams

The TYPE command
Login via GitHub to view this stage
Create a stream
Login via GitHub to view this stage
Validating entry IDs
Login via GitHub to view this stage
Partially auto-generated IDs
Login via GitHub to view this stage
Fully auto-generated IDs
Login via GitHub to view this stage
Query entries from stream
Login via GitHub to view this stage
Query with -
Login via GitHub to view this stage
Query with +
Login via GitHub to view this stage
Query single stream using XREAD
Login via GitHub to view this stage
Query multiple streams using XREAD
Login via GitHub to view this stage
Blocking reads
Login via GitHub to view this stage
Blocking reads without timeout
Login via GitHub to view this stage
Blocking reads using $
Login via GitHub to view this stage

Transactions

The INCR command (1/3)
Login via GitHub to view this stage
The INCR command (2/3)
Login via GitHub to view this stage
The INCR command (3/3)
Login via GitHub to view this stage
The MULTI command
Login via GitHub to view this stage
The EXEC command
Login via GitHub to view this stage
Empty transaction
Login via GitHub to view this stage
Queueing commands
Login via GitHub to view this stage
Executing a transaction
Login via GitHub to view this stage
The DISCARD command
Login via GitHub to view this stage
Failures within transactions
Login via GitHub to view this stage
Multiple transactions
Login via GitHub to view this stage
Build your own HTTP server
Build your own HTTP server

HTTP is the protocol that powers the web. In this challenge, you'll build a HTTP server that's capable of handling simple GET/POST requests, serving files and handling multiple concurrent connections.

Along the way, we'll learn about TCP connections, HTTP headers, HTTP verbs, handling multiple connections and more.

Bind to a port
Login via GitHub to view this stage
Respond with 200
Login via GitHub to view this stage
Extract URL path
Login via GitHub to view this stage
Respond with body
Login via GitHub to view this stage
Read header
Login via GitHub to view this stage
Concurrent connections
Login via GitHub to view this stage
Return a file
Login via GitHub to view this stage
Read request body
Login via GitHub to view this stage

HTTP Compression

Compression headers
Login via GitHub to view this stage
Multiple compression schemes
Login via GitHub to view this stage
Gzip compression
Login via GitHub to view this stage
Build your own Interpreter
Build your own Interpreter

This challenge follows the book Crafting Interpreters by Robert Nystrom.

In this challenge you'll build an interpreter for Lox, a simple scripting language. Along the way, you'll learn about tokenization, ASTs, tree-walk interpreters and more.

Before starting this challenge, make sure you've read the "Welcome" part of the book that contains these chapters:

These chapters don't involve writing code, so they won't be covered in this challenge. This challenge will start from chapter 4, Scanning.

Scanning: Empty file
Login via GitHub to view this stage
Scanning: Parentheses
Login via GitHub to view this stage
Scanning: Braces
Login via GitHub to view this stage
Scanning: Other single-character tokens
Login via GitHub to view this stage
Scanning: Lexical errors
Login via GitHub to view this stage
Scanning: Assignment & equality Operators
Login via GitHub to view this stage
Scanning: Negation & inequality operators
Login via GitHub to view this stage
Scanning: Relational operators
Login via GitHub to view this stage
Scanning: Division operator & comments
Login via GitHub to view this stage
Scanning: Whitespace
Login via GitHub to view this stage
Scanning: Multi-line errors
Login via GitHub to view this stage
Scanning: String literals
Login via GitHub to view this stage
Scanning: Number literals
Login via GitHub to view this stage
Scanning: Identifiers
Login via GitHub to view this stage
Scanning: Reserved words
Login via GitHub to view this stage

Parsing Expressions

Booleans & Nil
Login via GitHub to view this stage
Number literals
Login via GitHub to view this stage
String literals
Login via GitHub to view this stage
Parentheses
Login via GitHub to view this stage
Unary Operators
Login via GitHub to view this stage
Arithmetic operators (1/2)
Login via GitHub to view this stage
Arithmetic operators (2/2)
Login via GitHub to view this stage
Comparison operators
Login via GitHub to view this stage
Equality operators
Login via GitHub to view this stage
Syntactic errors
Login via GitHub to view this stage

Evaluating Expressions

Literals: Booleans & Nil
Login via GitHub to view this stage
Literals: Strings & Numbers
Login via GitHub to view this stage
Parentheses
Login via GitHub to view this stage
Unary Operators: Negation & Not
Login via GitHub to view this stage
Arithmetic Operators (1/2)
Login via GitHub to view this stage
Arithmetic Operators (2/2)
Login via GitHub to view this stage
String Concatenation
Login via GitHub to view this stage
Relational Operators
Login via GitHub to view this stage
Equality Operators
Login via GitHub to view this stage
Runtime Errors: Unary Operators
Login via GitHub to view this stage
Runtime Errors: Binary Operators (1/2)
Login via GitHub to view this stage
Runtime Errors: Binary Operators (2/2)
Login via GitHub to view this stage
Runtime Errors: Relational Operators
Login via GitHub to view this stage

Statements & State

Print: Generate output
Login via GitHub to view this stage
Print: Multiple statements
Login via GitHub to view this stage
Expression statements
Login via GitHub to view this stage
Variables: Declare variables
Login via GitHub to view this stage
Variables: Runtime Errors
Login via GitHub to view this stage
Variables: Initialize variables
Login via GitHub to view this stage
Variables: Redeclare variables
Login via GitHub to view this stage
Assignment operation
Login via GitHub to view this stage
Block syntax
Login via GitHub to view this stage
Scopes
Login via GitHub to view this stage

Control Flow

If statements
Login via GitHub to view this stage
Else statements
Login via GitHub to view this stage
Else-if statements
Login via GitHub to view this stage
Nested if statements
Login via GitHub to view this stage
Logical OR operator
Login via GitHub to view this stage
Logical AND operator
Login via GitHub to view this stage
While statements
Login via GitHub to view this stage
For statements
Login via GitHub to view this stage
Syntactic errors
Login via GitHub to view this stage

Functions

Native functions
Login via GitHub to view this stage
Functions without arguments
Login via GitHub to view this stage
Functions with arguments
Login via GitHub to view this stage
Syntax errors
Login via GitHub to view this stage
Return statements
Login via GitHub to view this stage
Higher order functions
Login via GitHub to view this stage
Runtime errors
Login via GitHub to view this stage
Function scope
Login via GitHub to view this stage
Closures
Login via GitHub to view this stage
Build your own Shell
Build your own Shell

A shell is a command-line interface that executes commands and manages processes. In this challenge, you'll build your own POSIX compliant shell that's capable of interpreting shell commands, running external programs and builtin commands like cd, pwd, echo and more.

Along the way, you'll learn about shell command parsing, REPLs, builtin commands, and more.

Print a prompt
Login via GitHub to view this stage
Handle missing commands
Login via GitHub to view this stage
REPL
Login via GitHub to view this stage
The exit builtin
Login via GitHub to view this stage
The echo builtin
Login via GitHub to view this stage
The type builtin: builtins
Login via GitHub to view this stage
The type builtin: executable files
Login via GitHub to view this stage
Run a program
Login via GitHub to view this stage

Navigation

The pwd builtin
Login via GitHub to view this stage
The cd builtin: Absolute paths
Login via GitHub to view this stage
The cd builtin: Relative paths
Login via GitHub to view this stage
The cd builtin: Home directory
Login via GitHub to view this stage
Build your own DNS server
Build your own DNS server

DNS is a protocol used to resolve domain names to IP addresses. In this challenge, you'll build a DNS server that's capable of responding to basic DNS queries.

Along the way you'll learn about the DNS protocol, DNS packet format, DNS record types, UDP servers and more.

Build your own grep
Build your own grep

Learn about regular expressions and how they're evaluated. Implement your own version of grep in Rust.

Match a literal character
Login via GitHub to view this stage
Match digits
Login via GitHub to view this stage
Match alphanumeric characters
Login via GitHub to view this stage
Positive Character Groups
Login via GitHub to view this stage
Negative Character Groups
Login via GitHub to view this stage
Combining Character Classes
Login via GitHub to view this stage
Start of string anchor
Login via GitHub to view this stage
End of string anchor
Login via GitHub to view this stage
Match one or more times
Login via GitHub to view this stage
Match zero or one times
Login via GitHub to view this stage
Wildcard
Login via GitHub to view this stage
Alternation
Login via GitHub to view this stage

Backreferences

Single Backreference
Login via GitHub to view this stage
Multiple Backreferences
Login via GitHub to view this stage
Nested Backreferences
Login via GitHub to view this stage
Build your own BitTorrent
Build your own BitTorrent

Learn about .torrent files and the famous BitTorrent protocol. Implement your own BitTorrent client in Rust.

Decode bencoded strings
Login via GitHub to view this stage
Decode bencoded integers
Login via GitHub to view this stage
Decode bencoded lists
Login via GitHub to view this stage
Decode bencoded dictionaries
Login via GitHub to view this stage
Parse torrent file
Login via GitHub to view this stage
Calculate info hash
Login via GitHub to view this stage
Piece hashes
Login via GitHub to view this stage
Discover peers
Login via GitHub to view this stage
Peer handshake
Login via GitHub to view this stage
Download a piece
Login via GitHub to view this stage
Download the whole file
Login via GitHub to view this stage

Magnet Links

Parse magnet link
Login via GitHub to view this stage
Announce extension support
Login via GitHub to view this stage
Send extension handshake
Login via GitHub to view this stage
Receive extension handshake
Login via GitHub to view this stage
Request metadata
Login via GitHub to view this stage
Receive metadata
Login via GitHub to view this stage
Download a piece
Login via GitHub to view this stage
Download the whole file
Login via GitHub to view this stage
Build your own SQLite
Build your own SQLite

Learn about B-Trees, the foundation of every relational database. Explore Rust's API for reading/writing files, and handling custom file formats.

Build your own Kafka
Build your own Kafka

Apache Kafka is a distributed event streaming platform often used for high-performance data pipelines. In this challenge, you'll build your own Kafka broker that's capable of serving basic requests.

Along the way you'll learn about TCP servers, the Kafka wire protocol and more.

Bind to a port
Login via GitHub to view this stage
Send Correlation ID
Login via GitHub to view this stage
Parse Correlation ID
Login via GitHub to view this stage
Parse API Version
Login via GitHub to view this stage
Handle APIVersions requests
Login via GitHub to view this stage

Concurrent Clients

Serial requests
Login via GitHub to view this stage
Concurrent requests
Login via GitHub to view this stage

Listing Partitions

Include DescribeTopicPartitions in APIVersions
Login via GitHub to view this stage
List for an unknown topic
Login via GitHub to view this stage
List for a single partition
Login via GitHub to view this stage
List for multiple partitions
Login via GitHub to view this stage
List for multiple topics
Login via GitHub to view this stage

Consuming Messages

Include Fetch in APIVersions
Login via GitHub to view this stage
Fetch with no topics
Login via GitHub to view this stage
Fetch with an unknown topic
Login via GitHub to view this stage
Fetch with an empty topic
Login via GitHub to view this stage
Fetch single message from disk
Login via GitHub to view this stage
Fetch multiple messages from disk
Login via GitHub to view this stage
Many more to come...
coming soon
We release new challenges based on user votes. Let us know what you'd like to see next!
challenge voting
Vote on upcoming challenges