Closed
Description
Given the following code: link
struct Struct {
let x: i32,
}
fn main() {
}
The current output is:
Compiling playground v0.0.1 (/playground)
error: expected identifier, found keyword `let`
--> src/main.rs:2:5
|
2 | let x: i32,
| ^^^ expected identifier, found keyword
error: could not compile `playground` due to previous error
Since normal variable declaration are done using a let
or other keywords in front and I accidentally made that typo due to muscle memory from creating regular variables. I think the ideal output for such a typo will be to suggest removing the let
and having a small note stating that let
is not required for struct variable declarations. (Note: the small note can be omitted if not necessary). This may be useful for beginners first getting used to the language's syntax.