Rust
Comprehensive Rust reference covering ownership, borrowing, structs, enums, traits, generics, error handling, async/await, concurrency, macros, and more.
Getting Started
Install Rust, create a project with Cargo, and run your first program.
Installation & Cargo
Install Rust with rustup and use Cargo to create and run projects.
Variables & Types
Variables, mutability, basic types, tuples, arrays, and type aliases.
Variables & Basic Types
Declare variables with let, control mutability, and use primitive types.
Strings
Understand &str vs String, conversions, and string operations.
&str vs String
The two string types, when to use each, and how to convert between them.
Control Flow
If expressions, loops, match, if let, and pattern matching.
If, Loops & Match
Conditional expressions, loops, and pattern matching.
Functions & Closures
Define functions, closures, and understand Fn traits.
Functions & Closures
Named functions, closures, and the Fn/FnMut/FnOnce traits.
Ownership & Borrowing
Rust's ownership system, borrowing rules, and Clone vs Copy.
Ownership & Borrowing
Move semantics, borrowing rules, and the Clone/Copy distinction.
Structs & Enums
Define custom types with structs and enums, and attach methods with impl.
Structs & Methods
Define structs and attach methods with impl blocks.
Enums
Define enums with variants that can hold data.
Traits
Define shared behavior with traits, derive common traits, and use From/Into.
Defining & Implementing Traits
Create traits, implement them for types, and use trait bounds.
Common Traits & Derive
Derive traits automatically and implement From/Into for conversions.
Generics & Lifetimes
Write generic code and annotate lifetimes for references.
Generics & Lifetimes
Generic functions, structs, and lifetime annotations.
Error Handling
Handle errors with Result, Option, the ? operator, and custom error types.
Result, Option & the ? Operator
Propagate errors idiomatically with Result<T, E> and the ? operator.
Collections & Iterators
Vec, HashMap, and iterator methods for transforming data.
Vec & HashMap
Dynamic arrays and key-value maps.
Iterators
Transform collections with iterator adaptors and consumers.
Smart Pointers
Box, Rc, Arc, RefCell, and Cow for advanced memory management.
Box, Rc, Arc & RefCell
Heap allocation, reference counting, and interior mutability.
Concurrency
Threads, channels, Arc, and Mutex for safe concurrent programming.
Threads, Channels & Mutex
Spawn threads, pass messages, and share state safely.
Async Programming
Async/await with tokio for non-blocking I/O.
Async/Await & Tokio
Write async functions and use the tokio runtime.
Macros & File I/O
Define macros with macro_rules! and read/write files with std::fs.
Macros
Write declarative macros with macro_rules! for code generation.
File I/O
Read and write files with std::fs.
Modules & Cargo
Organize code with modules and manage dependencies with Cargo.
Modules & Visibility
Organize code into modules with pub/use and file-based structure.
Testing
Write unit tests, integration tests, and use assert macros.
Writing Tests
Unit tests, integration tests, and test organization.