Explore the world of Rust closures in this 35-minute conference talk from Rust Linz, October 2021. Begin with an introduction to closure functionality in Rust, ideal for programmers familiar with closures in other languages. Delve into the syntax of Rust closures, including single-line syntax and type inference. Examine inline closures and function closures, then peek behind the scenes to understand their implementation. Learn about closure lifetimes and explore examples of Fn, FnMut, and FnOnce. Discover the reasons behind FnOnce and conclude with an in-depth look at the new disjoint capturing feature introduced in Rust 2021, illustrated through a "fairy tale" code sample.
Overview
Syllabus
Intro
Rust Closures
Syntax
Closure Syntax
Single Line Syntax
Type Inference
Inline Closure
Function Closure
Behind the scenes
Lifetime
Fn Mute Example
Fn Once Example
Why Fn Once
Disjoint Capturing
Taught by
Rust