Closure Capture
Create a variable multiplier set to 3. Then create a closure multiply that captures multiplier and multiplies its parameter by it. Print the result for 5 and 10.
Expected output:
text
5 x 3 = 15 10 x 3 = 30
Hints:
- The closure captures
multiplierfrom the outer scope let multiply = |x: i32| x * multiplier;
rust
fn main() {
}