diff --git a/restaurant/Cargo.toml b/restaurant/Cargo.toml new file mode 100644 index 0000000..678b365 --- /dev/null +++ b/restaurant/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "restaurant" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/restaurant/src/lib.rs b/restaurant/src/lib.rs new file mode 100644 index 0000000..dbe6d78 --- /dev/null +++ b/restaurant/src/lib.rs @@ -0,0 +1,49 @@ +mod front_of_house { + pub mod hosting { + fn add_to_waitlist() { + println!("hello") + } + + pub fn seat_at_table() { + add_to_waitlist(); + } + } + + mod serving { + fn take_order() {} + + fn serve_order() {} + + fn take_payment() {} + } +} + +mod back_of_house { + pub enum Appetizer { + Soup, + Salad, + } + + pub struct Breakfast { + pub toast: String, + seasonal_fruit: String, + } + + impl Breakfast { + pub fn summer(toast: &str) -> Breakfast { + Breakfast { + toast: String::from(toast), + seasonal_fruit: String::from("peaches"), + } + } + } +} + +pub fn eat_at_restaurant() { + let mut meal = back_of_house::Breakfast::summer("Rye"); + meal.toast = String::from("Wheat"); + println!("I'd like {} toast please!", meal.toast); + + let orderOne = back_of_house::Appetizer::Soup; + let orderTwo = back_of_house::Appetizer::Salad; +} \ No newline at end of file diff --git a/restaurant/src/main.rs b/restaurant/src/main.rs new file mode 100644 index 0000000..f7f1747 --- /dev/null +++ b/restaurant/src/main.rs @@ -0,0 +1,5 @@ +use restaurant::eat_at_restaurant; + +fn main() { + eat_at_restaurant(); +} \ No newline at end of file