mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-11 21:29:18 +00:00
me tomo el palo
This commit is contained in:
parent
9bb57f5687
commit
8f012403f2
@ -6,6 +6,10 @@
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum Message {
|
enum Message {
|
||||||
// TODO: define the different variants used below
|
// TODO: define the different variants used below
|
||||||
|
Move{x:i32, y:i32},
|
||||||
|
Echo (String),
|
||||||
|
ChangeColor(i32,i32,i32),
|
||||||
|
Quit
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Message {
|
impl Message {
|
||||||
|
|||||||
@ -2,10 +2,11 @@
|
|||||||
// Address all the TODOs to make the tests pass!
|
// Address all the TODOs to make the tests pass!
|
||||||
// Execute `rustlings hint enums3` or use the `hint` watch subcommand for a hint.
|
// Execute `rustlings hint enums3` or use the `hint` watch subcommand for a hint.
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
enum Message {
|
enum Message {
|
||||||
// TODO: implement the message variant types based on their usage below
|
Move(Point),
|
||||||
|
Echo(String),
|
||||||
|
ChangeColor(u8, u8, u8),
|
||||||
|
Quit,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Point {
|
struct Point {
|
||||||
@ -37,8 +38,13 @@ impl State {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn process(&mut self, message: Message) {
|
fn process(&mut self, message: Message) {
|
||||||
// TODO: create a match expression to process the different message variants
|
match message {
|
||||||
// Remember: When passing a tuple as a function argument, you'll need extra parentheses: fn function((t, u, p, l, e))
|
Message::Echo(s) => self.echo(s),
|
||||||
|
Message::Move(p) => self.move_position(p),
|
||||||
|
Message::ChangeColor(a, _, _) => self.change_color((a, 0, 255)), // Hardocded params
|
||||||
|
Message::Quit => self.quit(),
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,5 +10,6 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn current_favorite_color() -> String {
|
fn current_favorite_color() -> String {
|
||||||
"blue"
|
String::from("blue")
|
||||||
|
//"blue".to_string()
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user