me tomo el palo

This commit is contained in:
contre95 2023-01-10 00:08:43 +01:00
parent 9bb57f5687
commit 8f012403f2
3 changed files with 17 additions and 6 deletions

View File

@ -6,6 +6,10 @@
#[derive(Debug)]
enum Message {
// TODO: define the different variants used below
Move{x:i32, y:i32},
Echo (String),
ChangeColor(i32,i32,i32),
Quit
}
impl Message {

View File

@ -2,10 +2,11 @@
// Address all the TODOs to make the tests pass!
// Execute `rustlings hint enums3` or use the `hint` watch subcommand for a hint.
// I AM NOT DONE
enum Message {
// TODO: implement the message variant types based on their usage below
Move(Point),
Echo(String),
ChangeColor(u8, u8, u8),
Quit,
}
struct Point {
@ -37,8 +38,13 @@ impl State {
}
fn process(&mut self, message: Message) {
// TODO: create a match expression to process the different message variants
// Remember: When passing a tuple as a function argument, you'll need extra parentheses: fn function((t, u, p, l, e))
match message {
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(),
}
}
}

View File

@ -10,5 +10,6 @@ fn main() {
}
fn current_favorite_color() -> String {
"blue"
String::from("blue")
//"blue".to_string()
}