Rust Tutorial #13: Smart Pointers — Box, Rc, Arc

In the previous tutorial, we learned closures and iterators. Now we learn smart pointers — types that act like pointers but have extra capabilities. In Rust, the most common pointer is a reference (&T). References borrow data but do not own it. Smart pointers own the data they point to. They also add features like heap allocation, reference counting, and interior mutability. What Is a Smart Pointer? A smart pointer is a struct that: ...

March 26, 2026 · 9 min

Rust Tutorial #16: Collections — HashMap, BTreeMap, VecDeque

In the previous tutorial, we learned async programming with Tokio. Now we take a deep dive into Rust collections – HashMap, BTreeMap, HashSet, BTreeSet, VecDeque, and BinaryHeap. You already know Vec and basic HashMap. This tutorial covers the advanced features: the entry API, custom keys, range queries, set operations, sliding windows, and priority queues. HashMap – The Entry API The entry API is the most important HashMap feature to learn. It lets you insert or update values without looking up the key twice. ...

March 26, 2026 · 8 min

Rust Tutorial #12: Closures and Iterators

In the previous tutorial, we learned lifetimes. Now we learn two features that make Rust code clean and expressive: closures and iterators. Closures are anonymous functions you can store in variables and pass to other functions. Iterators let you process collections step by step. Together, they replace most loops with short, readable code. What Is a Closure? A closure is a function without a name. It can capture variables from its environment: ...

March 26, 2026 · 9 min

Rust Tutorial #11: Lifetimes — How Rust Prevents Dangling References

In the previous tutorial, we learned generics. Now we learn lifetimes — the last piece of Rust’s ownership system. Lifetimes answer one question: “How long does this reference live?” The Rust compiler uses lifetimes to make sure every reference is always valid. No dangling pointers. No use-after-free bugs. No segfaults. If you have struggled with lifetime errors, this tutorial will help. Most of the time, lifetimes are invisible — the compiler figures them out for you. But sometimes you need to tell the compiler what you mean. ...

March 26, 2026 · 9 min

Rust Tutorial #10: Generics — Write Once, Use Everywhere

In the previous tutorial, we learned traits — how to define shared behavior. Now we learn generics — how to write code that works with many types without repeating yourself. You already use generics every day in Rust. Vec<T>, Option<T>, Result<T, E> — these are all generic types. The T is a placeholder for any type. In this tutorial, you learn to write your own. Why Generics? Without generics, you would write separate functions for each type: ...

March 26, 2026 · 10 min

Rust Tutorial #9: Traits — Shared Behavior

In the previous tutorial, we learned error handling with Result and Option. Now we learn traits — Rust’s way to define shared behavior between types. If you know interfaces in Java, Kotlin, or TypeScript, traits are similar. A trait says “any type that implements me must have these methods.” But Rust traits go further — they support default methods, operator overloading, and dynamic dispatch. What Is a Trait? A trait defines a set of methods that a type must implement. Think of it as a contract. Any type that signs the contract must provide the required methods. ...

March 26, 2026 · 11 min

Rust Tutorial #8: Error Handling

In the previous tutorial, we learned enums and pattern matching. We also saw Option<T> for values that might not exist. Now we learn how Rust handles errors. Most languages use exceptions — you throw an error and hope someone catches it. Rust does not have exceptions. Instead, Rust uses types to represent errors. The compiler forces you to handle them. No surprise crashes. No unhandled exceptions. Two Kinds of Errors Rust splits errors into two categories: ...

March 26, 2026 · 7 min

Rust Tutorial #7: Enums and Pattern Matching

In the previous tutorial, we learned structs — types where every value has the same fields. But sometimes a value can be one of several different kinds. That is what enums are for. Enums in Rust are much more powerful than in most languages. In Java or Kotlin, enums are just named constants. In Rust, each variant can hold different data. Combined with pattern matching, enums become one of Rust’s best features. ...

March 26, 2026 · 6 min

Rust Tutorial #6: Structs and Methods

In the previous tutorial, we learned borrowing and references. Now we learn how to create custom types with structs and attach behavior to them with methods. If you have used classes in Kotlin, Java, or Python, structs will feel familiar. Rust does not have classes, but structs with impl blocks give you the same power — without inheritance. Defining a Struct A struct groups related data together: struct User { name: String, email: String, age: u32, active: bool, } Each field has a name and a type. This is similar to a data class in Kotlin or a class in Python. ...

March 26, 2026 · 7 min

Rust Tutorial #3: Variables, Types, and Functions

In the previous tutorial, we installed Rust and wrote “Hello, world!”. Now let’s learn the building blocks — variables, types, and functions. If you know Kotlin, Python, or JavaScript, most of this will feel familiar. But Rust has a few surprises — especially around mutability and shadowing. Variables: let and mut Immutable by Default In Rust, variables are immutable by default. You cannot change them after creation: let name = "Alex"; name = "Sam"; // ERROR: cannot assign twice to immutable variable This is the opposite of most languages. In Kotlin, val is immutable and var is mutable. In Rust, let is immutable and let mut is mutable. ...

March 26, 2026 · 9 min