Matchy matchy
This commit is contained in:
parent
ed29f7a221
commit
a87124ed2e
5
matchy/Cargo.lock
generated
Normal file
5
matchy/Cargo.lock
generated
Normal 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
9
matchy/Cargo.toml
Normal 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
22
matchy/src/main.rs
Normal 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));
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user