A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-30.rs
1fnmain(){
2letsq=|n:i64|n*n;
3letneg=|n|0-n;
4println!("{} {}",sq(4),neg(7i64));
5}
Closures
Answer & explanation
Console output
16 -7
Why
A closure parameter type can be written explicitly (`|n: i64|`) or left for the compiler to infer from use. `neg` has no annotation, so calling it with `7i64` locks its parameter to `i64`. `sq(4)` is 16 and `neg(7)` is -7.