To try everything Brilliant has to offer—free—for a full 30 days, visit https://brilliant.org/GreenTeaCoding/ . You’ll also get 20% off an annual premium subscription.
Watch the rest of this series: • Advanced Rust
New to Rust? Check out my fundamentals series:
• How to become a Rust Developer
Rust's for loop looks simple — but under the hood, it's a masterclass in trait design. In this video, we break down how `for item in &vec` actually works, why `IntoIterator` is implemented on references, and what this teaches us about designing our own traits.
We'll also unpack the desugaring of for loops, explain why `Deref` isn't enough to make iteration work on references, and highlight a key insight: how trait method receivers (`self` vs `&self`) change everything about how implementations behave — and why that’s a feature, not a limitation.
Whether you're curious about auto-borrowing, reference-based trait impls, or just love seeing how elegant Rust’s internals are, this episode delivers.
⏱️ Perfect for intermediate-to-advanced Rust devs who want to sharpen their understanding of ownership, iteration, and trait design.
Find me elsewhere:
🐘 Mastodon: https://mastodon.social/@GreenTeaCoding
#rustlang #advancedrust #rustprogramming #forloop #intorust #rusttraits #rustiterators #ownership #zerocostabstractions
Chapters:
00:00 Desugaring the for loop
02:15 Ownership vs Borrowing
03:12 Brilliant Sponsorship
04:33 IntoIterator
06:04 Vec's IntoIterator
08:31 Impl on &T
11:12 Outro
This video was sponsored by Brilliant
コメント