Learn Rust by Example
Practical, runnable Rust code examples covering everything from basic syntax to advanced concurrency. Each example includes explanations, key concepts, and difficulty ratings.
Explore by Topic
Choose a topic to start learning Rust step by step.
Basics
Variables, types, structs, enums, and fundamental Rust syntax.
Ownership
Ownership, borrowing, references, and move semantics.
Flow Control
if/else, loops, match, and pattern matching.
Traits
Trait definition, implementation, and trait objects.
Error Handling
Result, Option, ? operator, and custom errors.
Concurrency
Threads, channels, Arc, Mutex, and atomics.
Async
async/await, futures, and asynchronous programming.
Iterators
Iterator trait, adaptors, and lazy evaluation.
Popular Examples
Essential Rust patterns every developer should know.
AI Inference Batch Processing
Dynamic batching for AI inference in Rust using tokio channels and semaphores for high-throughput model serving.
AI Model Registry in Rust
Thread-safe model registry for serving multiple AI models in a single Rust inference server using Arc and RwLock.
Arc and Mutex
Share state between threads safely with Arc<Mutex<T>>.
Array and Slice
Fixed-size arrays and dynamic slices in Rust.
Associated Types
Define associated types in traits for cleaner generic code.
Async Basic
Introduction to async/await in Rust with futures.
Async Spawn Tasks
Spawn concurrent tasks with tokio::spawn.
Async Streams
Use async streams for asynchronous iteration.
Atomic Types
Use atomic types for lock-free concurrent programming.
Common Compiler Errors
Understand and fix Rust compiler errors quickly.
mismatched types (expected, found)
Learn what Rust error E0308 means, why it happens, and how to fix it with practical code examples.
use of moved value
Learn what Rust error E0382 means, why it happens, and how to fix it with practical code examples.
cannot borrow more than once at a time
Learn what Rust error E0499 means, why it happens, and how to fix it with practical code examples.
cannot move out of borrowed content
Learn what Rust error E0507 means, why it happens, and how to fix it with practical code examples.
borrowed value does not live long enough
Learn what Rust error E0597 means, why it happens, and how to fix it with practical code examples.
no method named found for type
Learn what Rust error E0599 means, why it happens, and how to fix it with practical code examples.
Engineering Guides
Long-form, high-intent Rust content for debugging, architecture, and production decisions.
Building LLM Applications with Rust
Comprehensive guide to building Large Language Model (LLM) applications in Rust. Covers OpenAI API integration, local model inference, prompt engineering, and streaming responses.
LLM API Gateway in Rust
Build a production LLM API gateway in Rust with Axum: multi-provider routing, rate limiting, cost tracking, request logging, and streaming proxy for OpenAI and Anthropic.
LLM Rust Anti-Patterns
Anti-patterns to avoid when building LLM applications in Rust: blocking on streaming, over-prompting, synchronous API calls in async context, and missing error boundaries.
LLM Rust Benchmarking
Benchmark LLM application performance in Rust: measure TTFT, throughput, cache hit rates, and compare provider latency distributions using Criterion and custom instrumentation.
LLM Rust Decision Matrix
How to choose the right LLM integration approach for Rust projects: OpenAI API vs Anthropic vs local models, streaming vs batch, managed vs self-hosted inference.
LLM Rust Interview Q&A
Top interview questions and answers about building LLM applications in Rust. Covers streaming APIs, prompt design, context management, rate limiting, and system architecture for AI engineers.
Ready to start learning?
Begin with the basics and work your way up to advanced Rust patterns.