From 0bae9c88d57461bd5b575bd7ff6c6a4935894a1e Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Sun, 19 Jan 2025 18:18:50 +0100 Subject: [PATCH] Split up `restaurant` package --- restaurant/src/back_of_house.rs | 20 ++++++++++++ restaurant/src/front_of_house.rs | 3 ++ restaurant/src/front_of_house/hosting.rs | 3 ++ restaurant/src/front_of_house/serving.rs | 5 +++ restaurant/src/lib.rs | 39 ++---------------------- 5 files changed, 33 insertions(+), 37 deletions(-) create mode 100644 restaurant/src/back_of_house.rs create mode 100644 restaurant/src/front_of_house.rs create mode 100644 restaurant/src/front_of_house/hosting.rs create mode 100644 restaurant/src/front_of_house/serving.rs diff --git a/restaurant/src/back_of_house.rs b/restaurant/src/back_of_house.rs new file mode 100644 index 0000000..e28f98d --- /dev/null +++ b/restaurant/src/back_of_house.rs @@ -0,0 +1,20 @@ +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"), + } + } +} + +fn fix_incorrect_order() { + cook_order(); + crate::deliver_order(); +} + +fn cook_order() {} diff --git a/restaurant/src/front_of_house.rs b/restaurant/src/front_of_house.rs new file mode 100644 index 0000000..9b57252 --- /dev/null +++ b/restaurant/src/front_of_house.rs @@ -0,0 +1,3 @@ +pub mod hosting; + +mod serving; diff --git a/restaurant/src/front_of_house/hosting.rs b/restaurant/src/front_of_house/hosting.rs new file mode 100644 index 0000000..e61efc5 --- /dev/null +++ b/restaurant/src/front_of_house/hosting.rs @@ -0,0 +1,3 @@ +pub fn add_to_waitlist() {} + +fn seat_at_table() {} diff --git a/restaurant/src/front_of_house/serving.rs b/restaurant/src/front_of_house/serving.rs new file mode 100644 index 0000000..141d8fd --- /dev/null +++ b/restaurant/src/front_of_house/serving.rs @@ -0,0 +1,5 @@ +fn take_order() {} + +fn serve_order() {} + +fn take_payment() {} diff --git a/restaurant/src/lib.rs b/restaurant/src/lib.rs index 6579106..9bfa793 100644 --- a/restaurant/src/lib.rs +++ b/restaurant/src/lib.rs @@ -1,43 +1,8 @@ fn deliver_order() {} -mod front_of_house { - pub mod hosting { - pub fn add_to_waitlist() {} +mod front_of_house; - fn seat_at_table() {} - } - - mod serving { - fn take_order() {} - - fn serve_order() {} - - fn take_payment() {} - } -} - -mod back_of_house { - 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"), - } - } - } - - fn fix_incorrect_order() { - cook_order(); - super::deliver_order(); - } - - fn cook_order() {} -} +mod back_of_house; pub fn eat_at_restaurant() { // Order a breakfast in the summer with Rye toast