Exercise 1 · Chapter: Closures & IteratorsRequired+50 XP
Simple Closure
Create a closure called square that takes an i32 and returns its square. Use it to print the square of 7.
Expected output:
Square of 7: 49
Hints:
let square = |x: i32| x * x;- Call it like a function:
square(7)
rust
fn main() {
}
Output
Run your code to see the output here.