Closed
Description
Creating a closure and directly calling it:
fn main() { let _ = ||{}(); }
Errors:
Compiling playground v0.0.1 (/playground)
error[E0618]: expected function, found `()`
--> src/main.rs:1:23
|
1 | fn main() { let _ = ||{}(); }
| ^^^^ not a function
error: aborting due to previous error
For more information about this error, try `rustc --explain E0618`.
Which doesn't really hint at what the problem is. The problem is that the closure must be surrounded by ()
- playground:
fn main() { let _ = (||{})(); }