Solve enum3

This commit is contained in:
Jonathan Zernik 2022-06-07 23:45:49 -07:00
parent 53c7b873de
commit 3bdf1774da

View File

@ -1,10 +1,12 @@
// enums3.rs
// Address all the TODOs to make the tests pass!
// I AM NOT DONE
enum Message {
// TODO: implement the message variant types based on their usage below
ChangeColor((u8, u8, u8)),
Echo(String),
Move(Point),
Quit,
}
struct Point {
@ -37,6 +39,20 @@ impl State {
fn process(&mut self, message: Message) {
// TODO: create a match expression to process the different message variants
match message {
Message::ChangeColor((r, g, b)) => {
self.change_color((r, g, b));
}
Message::Move(p) => {
self.move_position(p);
}
Message::Quit => {
self.quit();
}
Message::Echo(s) => {
self.echo(s);
}
}
}
}