You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm new at Rust language and I'm having a lot of fun with the lang, rustlings and ytb videos, but, doing some rustlings exercises, i became stucked at enums2.rs.
I'll try to be as brief as possible:
I spent a time looking at enums2.rs solutions on gitHub Gist and I realize that the solutions was made through an older rustlings version.
On the link marked above, we have something like this:
#[derive(Debug)]enumMessage{// TODO: define the different variants used below}implMessage{fncall(&self){println!("{:?}", &self);}}fnmain(){let messages = [Message::Move{x:10,y:30},// NOTE: that line it's important <<<Message::Echo(String::from("hello world")),Message::ChangeColor(200,255,255),Message::Quit];for message in&messages {
message.call();}}
But, in my local rustlings, i have something like:
fnmain(){let messages = [Message::Resize{width:10,height:30,},Message::Move(Point{x:10,y:15}),// NOTE: is exactly this line <<<Message::Echo(String::from("hello world")),Message::ChangeColor(200,255,255),Message::Quit,];for message in&messages {
message.call();}}
To solve the exercise, i did:
#[derive(Debug)]enumMessage{// TODO: Define the different variants used below.Resize{width:i32,height:i32},Move(Point{x:i32,y:i32}),Echo(String),ChangeColor(i32,i32,i32),Quit}
but, when running the program, I've got:
error: expected one of `!`, `(`, `)`, ` `, `,`, `::`, or `<`, found `{`
--> exercises/08_enums/enums2.rs:13:17
|
10 | enum Message {
| ------- while parsing this enum
...
13 | Move( Point { x: i32, y: i32 } ),
| ^ expected one of 7 possible tokens
|
= help: enum variants can be `Variant`, `Variant = <integer>`, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }`
error[E0061]: this enum variant takes 0 arguments but 1 argument was supplied
--> exercises/08_enums/enums2.rs:31:9
|
31 | Message::Move(Point { x: 10, y: 15 }), // NOTE: is exactly this line <<<
| ^^^^^^^^^^^^^ ----------------------
| |
| unexpected argument of type `Point`
| help: remove the extra argument
|
note: tuple variant defined here
--> exercises/08_enums/enums2.rs:13:5
|
13 | Move( Point { x: i32, y: i32 } ),
| ^^^^
For more information about this error, try `rustc --explain E0061`.
error: could not compile `exercises` (bin "enums2") due to 2 previous errors
The way that I think doesn't seem to be wrong. I know exactly what i need to do to beat the task, but that doesn't seem like the way I should do it. Can someone help me?
The text was updated successfully, but these errors were encountered:
I'm new at Rust language and I'm having a lot of fun with the lang, rustlings and ytb videos, but, doing some rustlings exercises, i became stucked at enums2.rs.
I'll try to be as brief as possible:
I spent a time looking at enums2.rs solutions on gitHub Gist and I realize that the solutions was made through an older rustlings version.
On the link marked above, we have something like this:
But, in my local rustlings, i have something like:
To solve the exercise, i did:
but, when running the program, I've got:
The way that I think doesn't seem to be wrong. I know exactly what i need to do to beat the task, but that doesn't seem like the way I should do it. Can someone help me?
The text was updated successfully, but these errors were encountered: