Back to Challenges
[RUST CHALLENGES]

30 Days of Rust

Master Rust programming with 30 daily coding challenges. Learn ownership, borrowing, lifetimes, and Solana program primitives through hands-on practice.

30 challenges Easy Medium Hard
#1Easy

Day 1: Hello Rust

Your first Rust program! Learn about variables, basic types, and how to print output. Create a greeting message using let bindings.

BasicsVariablesprintln!
Start
#2Easy

Day 2: Primitive Types

Explore Rust's primitive types: integers, floats, booleans, and tuples. Calculate the sum and product of two numbers.

TypesNumbersTuples
Start
#3Easy

Day 3: Functions

Master Rust functions: parameters, return types, and the difference between expressions and statements. Implement a temperature converter.

FunctionsExpressionsReturn
Start
#4Easy

Day 4: Control Flow

Learn control flow with if/else, match expressions, and loops. Implement FizzBuzz for a single number.

if/elsematchLoops
Start
#5Easy

Day 5: Ownership Basics

Understand Rust's ownership system: move semantics, scope, and when values are dropped. Fix a program with ownership errors.

OwnershipMoveClone
Start
#6Easy

Day 6: References & Borrowing

Learn to borrow values with references (&T and &mut T). Modify a value through a mutable reference.

ReferencesBorrowing&mut
Start
#7Easy

Day 7: Slices

Work with slices: views into contiguous sequences. Extract the first word from a string.

Slices&str&[T]
Start
#8Easy

Day 8: Structs

Define and use structs to create custom data types. Build a simple User struct with fields.

StructsDataTypes
Start
#9Medium

Day 9: Enums & Option

Master enums and the Option type. Implement safe division that handles division by zero.

EnumsOptionPattern Matching
Start
#10Medium

Day 10: Methods & impl

Add behavior to structs with impl blocks. Create a Rectangle with area and perimeter methods.

Methodsimplself
Start
#11Medium

Day 11: Result & Error Handling

Handle errors gracefully with Result<T, E>. Parse a string to a number with proper error handling.

ResultError Handling?
Start
#12Medium

Day 12: Vectors

Work with Vec<T>, Rust's growable array. Calculate the sum and find the maximum of a vector.

VecCollectionsIteration
Start
#13Medium

Day 13: Strings

Understand String vs &str and string manipulation. Reverse the words in a sentence.

String&strUTF-8
Start
#14Medium

Day 14: HashMaps

Use HashMaps to store key-value pairs. Count the frequency of characters in a string.

HashMapCollectionsEntry API
Start
#15Medium

Day 15: Generics

Write flexible code with generics. Implement a generic function to find the largest element.

GenericsType ParametersReusability
Start
#16Medium

Day 16: Traits

Define shared behavior with traits. Create a Describable trait and implement it for multiple types.

TraitsPolymorphismimpl Trait
Start
#17Hard

Day 17: Trait Objects

Use trait objects for runtime polymorphism. Store different types in a single collection.

dyn TraitDynamic DispatchBox
Start
#18Hard

Day 18: Lifetimes

Understand lifetime annotations. Return the longer of two string slices safely.

Lifetimes'aReferences
Start
#19Medium

Day 19: Iterators

Master iterator adapters. Transform and filter collections functionally.

Iteratormapfilter+1
Start
#20Medium

Day 20: Closures

Use closures to capture environment. Implement a counter factory.

ClosuresFnFnMut+1
Start
#21Medium

Day 21: Modules

Organize code with modules. Understand pub, mod, and use keywords.

Modulespubuse+1
Start
#22Hard

Day 22: Smart Pointers

Explore smart pointers: Box for heap allocation, Rc for shared ownership.

BoxRcRefCell
Start
#23Medium

Day 23: Derive Macros

Use derive macros to auto-implement common traits. Essential for Solana development!

deriveDebugClone+1
Start
#24Medium

Day 24: Attributes

Use attributes for conditional compilation and memory layout control.

Attributes#[cfg]#[repr]
Start
#25Hard

Day 25: Byte Serialization

Manually serialize and deserialize data to bytes. Foundation for Borsh!

BytesSerialization[u8]
Start
#26Hard

Day 26: Working with Bytes

Build a Pubkey-like struct and work with byte arrays - essential for Solana!

BytesPubkeyEndianness
Start
#27Hard

Day 27: The From Trait

Implement type conversions with From/Into traits. Used heavily in Solana programs!

FromIntoConversions
Start
#28Hard

Day 28: Error Enums

Create custom error enums with numeric codes - the Solana program error pattern!

ErrorEnumsFrom
Start
#29Hard

Day 29: Account Validation

Implement Solana-style account validation patterns with discriminators.

ValidationAccountsPatterns
Start
#30Hard

Day 30: Capstone - State Machine

Build a complete Solana-style state machine combining all concepts learned!

CapstoneState MachineSolana Patterns
Start
    30 Days of Rust - All Challenges | learn.sol