mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-11 13:19:18 +00:00
19 lines
441 B
Rust
19 lines
441 B
Rust
// enums1.rs
|
|
// No hints this time! ;)
|
|
|
|
#[derive(Debug)]
|
|
enum Message {
|
|
// TODO: define a few types of messages as used below
|
|
Quit,
|
|
Echo(String),
|
|
Move { x: i32, y: i32 },
|
|
ChangeColor(i32, i32, i32),
|
|
}
|
|
|
|
fn main() {
|
|
println!("{:?}", Message::Quit);
|
|
println!("{:?}", Message::Echo(String::from("Hello")));
|
|
println!("{:?}", Message::Move { x: 4, y: 5 });
|
|
println!("{:?}", Message::ChangeColor(0, 255, 78));
|
|
}
|