Exerpad
🔥0
0 XP
Lv.1 Beginner
Log In

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:

text
Square of 7: 49

Hints:

  • let square = |x: i32| x * x;
  • Call it like a function: square(7)
rust
fn main() {
}