diff options
| author | Carol (Nichols || Goulding) <carol.nichols@gmail.com> | 2015-09-16 09:49:09 -0400 |
|---|---|---|
| committer | Carol (Nichols || Goulding) <carol.nichols@gmail.com> | 2015-09-16 09:49:09 -0400 |
| commit | 253ff9d75c0312f5486e5a5eaa5be12ad65ee696 (patch) | |
| tree | 0ea54ee89c2491aa48c9d7d04866dc8957cb4b31 | |
| parent | 662c651c6fecbcb32fc63323f1d257d60b51bff8 (diff) | |
Create ex5.rs
| -rw-r--r-- | ex5.rs | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -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); +} |
