diff --git a/matchy/Cargo.lock b/matchy/Cargo.lock new file mode 100644 index 0000000..102fc2e --- /dev/null +++ b/matchy/Cargo.lock @@ -0,0 +1,5 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "matchy" +version = "0.1.0" diff --git a/matchy/Cargo.toml b/matchy/Cargo.toml new file mode 100644 index 0000000..be71289 --- /dev/null +++ b/matchy/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "matchy" +version = "0.1.0" +authors = ["Dan Buch "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/matchy/src/main.rs b/matchy/src/main.rs new file mode 100644 index 0000000..ee4f6e9 --- /dev/null +++ b/matchy/src/main.rs @@ -0,0 +1,22 @@ +enum Coin { + Penny, + Nickel, + Dime, + Quarter, +} + +fn value_in_cents(coin: Coin) -> u8 { + match coin { + Coin::Penny => 1, + Coin::Nickel => 5, + Coin::Dime => 10, + Coin::Quarter => 25, + } +} + +fn main() { + println!("Penny is {:?}", value_in_cents(Coin::Penny)); + println!("Nickel is {:?}", value_in_cents(Coin::Nickel)); + println!("Dime is {:?}", value_in_cents(Coin::Dime)); + println!("Quarter is {:?}", value_in_cents(Coin::Quarter)); +}