This repository has been archived on 2023-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
rustlings-exercises-completed/exercises/ex5.rs

23 lines
442 B
Rust
Raw Normal View History

2018-02-22 00:09:53 -06:00
// ex5.rs
2015-09-16 08:49:09 -05:00
// Make me compile!
enum Reaction<'a> {
Sad(&'a str),
Happy(&'a str),
}
fn express(sentiment: Reaction) {
match sentiment {
Reaction::Sad(s) => println!(":( {}", s),
Reaction::Happy(s) => println!(":) {}", s),
}
}
fn main () {
let x = Reaction::Happy("It's a great day for Rust!");
express(x);
express(x);
let y = Reaction::Sad("This code doesn't compile yet.");
express(y);
}