Skip to content

Commit

Permalink
Create ex5.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
carols10cents committed Sep 16, 2015
1 parent 662c651 commit 253ff9d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions ex5.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 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);
}

0 comments on commit 253ff9d

Please sign in to comment.