Loading video player...
Mastering Rust fundamentals is all about understanding how data flows through your code. In this livestream, bashbunni dives deep into two of the most powerful features in the Rust programming language: Closures and Iterators. Walking through the JetBrains Academy Rust course, we explore how closures capture their environment and how iterators provide a lazy, efficient way to process collections. Whether you're coming from a background in Python, Go, or C++, this session breaks down the "ceremony" of Rust syntax into actionable coding patterns. What we cover in this session: - Rust Closures: Understanding anonymous functions, type inference, and how they differ from standard functions. - Capturing the Environment: A breakdown of the three ways closures capture values (Borrowing, Mutable Borrowing, and Ownership/Move). - Iterators & Lazy Evaluation: How the Iterator trait works, using the next method, and why iterators are "lazy" until consumed. - Iterator Adapters vs. Consuming Adapters: Practical examples of using map, filter, sum, and collect. - Hands-on Coding: Real-time problem solving, from sorting inventory to building factorials without loops or recursion. Beyond the code, we chat about the realities of being a developer—from managing screen time and health to the ethics of open-source software and the future of AI-generated code. Chapters: 00:00 - Technical difficulties & intro 01:40 - Chatting about migraines, hydration, and screen time 07:50 - Intro to Rust Closures (Anonymous Functions) 10:55 - Example: T-shirt company inventory & closure syntax 18:18 - Closure type inference vs. function definitions 22:20 - Comparing closures and lambdas 29:50 - Three ways closures capture values (Borrowing & Ownership) 33:20 - Immutable vs. Mutable borrows in practice 39:15 - Using the move keyword for forced ownership 50:28 - Intro to Iterator Traits (Fn, FnMut, FnOnce) 52:18 - Sorting slices with sort_by_key 59:00 - Debugging FnOnce errors and value moves 01:03:00 - Exercise: Filtering elements with closures 01:07:58 - Deep dive into Iterators & Lazy Evaluation 01:14:15 - Discussion: Learning fundamentals vs. jumping into projects 01:21:50 - The Iterator trait and the next method 01:25:50 - Consuming vs. Borrowing iterators (iter, into_iter, iter_mut) 01:36:50 - Consuming adapters (e.g., sum, collect) 01:40:10 - Iterator adapters (e.g., map, filter) 01:44:00 - Discussion: Career goals, content creation, and open-source ethics 02:11:00 - Iterator exercises: Fruits & Strings 02:33:15 - Challenge: Capitalizing strings in a vector 03:01:10 - Challenge: Safe division with Result and Option 03:15:05 - Factorial exercise (Iterators without loops/recursion) 03:21:00 - Final exercise: HashMaps & Nested Iterators 03:29:10 - Wrap up & Raiding Alveus Sanctuary