Closed
Description
fn main() {
let sum: i32 = [1,2,3].iter().inspect(|n| dbg!(n) ).sum();
}
This will suggest adding a ;
error[E0308]: mismatched types
--> src/main.rs:3:43
|
3 | let sum: i32 = [1,2,3].iter().inspect(|n| dbg!(n) ).sum();
| ^^^^^^^
| |
| expected `()`, found `&&{integer}`
| expected this to be `()`
| help: consider using a semicolon here
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
But doing so will "break" the code even more and not fix the error:
error: expected one of `)`, `,`, `.`, `?`, or an operator, found `;`
--> src/main.rs:2:50
|
2 | let sum: i32 = [1,2,3].iter().inspect(|n| dbg!(n); ).sum();
| ^ expected one of `)`, `,`, `.`, `?`, or an operator
error[E0308]: mismatched types
--> src/main.rs:2:43
|
2 | let sum: i32 = [1,2,3].iter().inspect(|n| dbg!(n); ).sum();
| ^^^^^^^
| |
| expected `()`, found `&&{integer}`
| expected this to be `()`
| help: consider using a semicolon here
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
Could rust suggest adding { }
around the macro?