progress(enums + strings): ___

This commit is contained in:
2026-07-26 01:22:48 +02:00
parent 3caf0b31ec
commit f0f6a72101
7 changed files with 33 additions and 11 deletions
+5
View File
@@ -1,6 +1,11 @@
#[derive(Debug)]
enum Message {
// TODO: Define a few types of messages as used below.
Resize,
Move,
Echo,
ChangeColor,
Quit,
}
fn main() {
+5
View File
@@ -7,6 +7,11 @@ struct Point {
#[derive(Debug)]
enum Message {
// TODO: Define the different variants used below.
Resize { width: u64, height: u64 },
Move(Point),
Echo(String),
ChangeColor(u64, u64, u64),
Quit,
}
impl Message {
+7
View File
@@ -46,6 +46,13 @@ impl State {
fn process(&mut self, message: Message) {
// TODO: Create a match expression to process the different message
// variants using the methods defined above.
match message {
Message::Resize { width, height } => self.resize(width, height),
Message::Move(point) => self.move_position(point),
Message::Echo(s) => self.echo(s),
Message::ChangeColor(red, green, blue) => self.change_color(red, green, blue),
Message::Quit => self.quit(),
}
}
}