Matchy matchy

This commit is contained in:
Dan Buch 2020-12-20 11:02:00 -05:00
parent ed29f7a221
commit a87124ed2e
Signed by: meatballhat
GPG Key ID: 9685130D8B763EA7
3 changed files with 36 additions and 0 deletions

5
matchy/Cargo.lock generated Normal file
View File

@ -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"

9
matchy/Cargo.toml Normal file
View File

@ -0,0 +1,9 @@
[package]
name = "matchy"
version = "0.1.0"
authors = ["Dan Buch <dan@meatballhat.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

22
matchy/src/main.rs Normal file
View File

@ -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));
}