1
0
Fork 0
mirror of https://github.com/notohh/rustlings.git synced 2024-12-20 15:38:09 -05:00
rustlings/exercises/08_enums/enums2.rs
2024-07-05 14:11:03 +02:00

35 lines
601 B
Rust

#![allow(dead_code)]
#[derive(Debug)]
struct Point {
x: u64,
y: u64,
}
#[derive(Debug)]
enum Message {
// TODO: Define the different variants used below.
}
impl Message {
fn call(&self) {
println!("{self:?}");
}
}
fn main() {
let messages = [
Message::Resize {
width: 10,
height: 30,
},
Message::Move(Point { x: 10, y: 15 }),
Message::Echo(String::from("hello world")),
Message::ChangeColor(200, 255, 255),
Message::Quit,
];
for message in &messages {
message.call();
}
}