Uploaded October 2024 | Updated November 2026, 3 hours ago
Full Rust course: youtube.com/watch?v=R33h77nrMqc&list=PLPoSdR46FgI412aItyJhj2bF66cudB6Qs&index=1&t=4s
Fullstack Rust Web Application:
youtu.be/FYVbt6YFMsM?si=7X5l0KCD39WIsICv
Important links:
Rust book: mybook.to/YJI6DI
Rust Workbook: francescociulla.gumroad.com/l/rustworkbook
Rust Cheatsheet: francescociulla.gumroad.com/l/rustcheatsheet
In this video, we dive into Closures in Rust, exploring their syntax, key features, and how they capture variables from their environment. We'll cover how closures borrow variables immutably, mutably, or take ownership, as well as a recap of closure traits like Fn, FnMut, and FnOnce. By the end, you'll understand the differences between functions and closures and how to use closures as function parameters.
Closures in Rust: Anonymous Functions that Capture Their Environment
0:00 Introduction to Closures
0:45 Key features of Closures
2:07 Syntax of a Closure - A first example
3:37 More examples: Parameters type inferred depending on the type of arguments
6:50 How to capture variables with closures: Capturing by immutably borrowing
8:00 Borrowing a variable mutably with Closures
9:51 Taking ownership of variables with Closures (with drop)
12:28 Closure traits recap: Fn, FnMut, FnOnce
13:03 Closures as function parameters
15:00 Differences between Functions and Closures
17:18 Conclusion
GitHub link: github.com/FrancescoXX/closures-in-rust
Full Rust course: youtube.com/watch?v=R33h77nrMqc&list=PLPoSdR46FgI412aItyJhj2bF66cudB6Qs&index=1&t=4s
Fullstack Rust Web Application:
youtu.be/FYVbt6YFMsM?si=7X5l0KCD39WIsICv
Important links:
Rust book: mybook.to/YJI6DI
Rust Workbook: francescociulla.gumroad.com/l/rustworkbook
Rust Cheatsheet: francescociulla.gumroad.com/l/rustcheatsheet
In this video, we dive into Closures in Rust, exploring their syntax, key features, and how they capture variables from their environment. We'll cover how closures borrow variables immutably, mutably, or take ownership, as well as a recap of closure traits like Fn, FnMut, and FnOnce. By the end, you'll understand the differences between functions and closures and how to use closures as function parameters.
Closures in Rust: Anonymous Functions that Capture Their Environment
0:00 Introduction to Closures
0:45 Key features of Closures
2:07 Syntax of a Closure - A first example
3:37 More examples: Parameters type inferred depending on the type of arguments
6:50 How to capture variables with closures: Capturing by immutably borrowing
8:00 Borrowing a variable mutably with Closures
9:51 Taking ownership of variables with Closures (with drop)
12:28 Closure traits recap: Fn, FnMut, FnOnce
13:03 Closures as function parameters
15:00 Differences between Functions and Closures
17:18 Conclusion
GitHub link: github.com/FrancescoXX/closures-in-rust










