mirror of https://github.com/KaiserY/trpl-zh-cn
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
558 B
26 lines
558 B
3 years ago
|
enum Color {
|
||
|
Rgb(i32, i32, i32),
|
||
|
Hsv(i32, i32, i32),
|
||
|
}
|
||
|
|
||
|
enum Message {
|
||
|
Quit,
|
||
|
Move { x: i32, y: i32 },
|
||
|
Write(String),
|
||
|
ChangeColor(Color),
|
||
|
}
|
||
|
|
||
|
fn main() {
|
||
|
let msg = Message::ChangeColor(Color::Hsv(0, 160, 255));
|
||
|
|
||
|
match msg {
|
||
2 years ago
|
Message::ChangeColor(Color::Rgb(r, g, b)) => {
|
||
|
println!("Change color to red {r}, green {g}, and blue {b}");
|
||
|
}
|
||
|
Message::ChangeColor(Color::Hsv(h, s, v)) => {
|
||
|
println!("Change color to hue {h}, saturation {s}, value {v}")
|
||
|
}
|
||
3 years ago
|
_ => (),
|
||
|
}
|
||
|
}
|