diff --git a/chapter7/restaurant/Cargo.lock b/chapter7/restaurant/Cargo.lock index ba86874..c9de552 100644 --- a/chapter7/restaurant/Cargo.lock +++ b/chapter7/restaurant/Cargo.lock @@ -2,6 +2,74 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "getrandom" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "libc" +version = "0.2.144" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + [[package]] name = "restaurant" version = "0.1.0" +dependencies = [ + "rand", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" diff --git a/chapter7/restaurant/Cargo.toml b/chapter7/restaurant/Cargo.toml index 678b365..075ab63 100644 --- a/chapter7/restaurant/Cargo.toml +++ b/chapter7/restaurant/Cargo.toml @@ -6,3 +6,4 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +rand = "0.8.5" diff --git a/chapter7/restaurant/src/front_of_house.rs b/chapter7/restaurant/src/front_of_house.rs new file mode 100644 index 0000000..4873487 --- /dev/null +++ b/chapter7/restaurant/src/front_of_house.rs @@ -0,0 +1,4 @@ +pub mod hosting; + +pub mod serving + diff --git a/chapter7/restaurant/src/front_of_house/hosting.rs b/chapter7/restaurant/src/front_of_house/hosting.rs new file mode 100644 index 0000000..2ba7b55 --- /dev/null +++ b/chapter7/restaurant/src/front_of_house/hosting.rs @@ -0,0 +1,2 @@ +pub fn add_to_waitlist() {} +pub fn seat_at_table() {} diff --git a/chapter7/restaurant/src/front_of_house/serving.rs b/chapter7/restaurant/src/front_of_house/serving.rs new file mode 100644 index 0000000..6f48210 --- /dev/null +++ b/chapter7/restaurant/src/front_of_house/serving.rs @@ -0,0 +1,3 @@ + pub fn take_order() {} + pub fn serve_order() {} + pub fn take_payent() {} diff --git a/chapter7/restaurant/src/lib.rs b/chapter7/restaurant/src/lib.rs index cbebbff..4e06d81 100644 --- a/chapter7/restaurant/src/lib.rs +++ b/chapter7/restaurant/src/lib.rs @@ -1,14 +1,7 @@ -pub mod front_of_house { - pub mod hosting { - pub fn add_to_waitlist() {} - pub fn seat_at_table() {} - } - pub mod serving { - pub fn take_order() {} - pub fn serve_order() {} - pub fn take_payent() {} - } -} +mod front_of_house; + +pub use crate::front_of_house::hosting; + fn deliver_order() {} mod back_of_house { @@ -37,12 +30,9 @@ mod back_of_house { } -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 _order1 = back_of_house::Appetizer::Soup; - let _order2 = back_of_house::Appetizer::Salad; - ; +mod customer { + use crate::front_of_house::hosting; + pub fn eat_at_restaurant() { + hosting::add_to_waitlist(); + } }