mirror of
https://github.com/sunface/rust-by-practice.git
synced 2025-06-25 05:29:41 +00:00
add practice projects
This commit is contained in:
7
practices/hello-package/src/back_of_house.rs
Normal file
7
practices/hello-package/src/back_of_house.rs
Normal file
@ -0,0 +1,7 @@
|
||||
use crate::front_of_house;
|
||||
pub fn fix_incorrect_order() {
|
||||
cook_order();
|
||||
front_of_house::serving::serve_order();
|
||||
}
|
||||
|
||||
pub fn cook_order() {}
|
6
practices/hello-package/src/front_of_house/hosting.rs
Normal file
6
practices/hello-package/src/front_of_house/hosting.rs
Normal file
@ -0,0 +1,6 @@
|
||||
pub fn add_to_waitlist() {}
|
||||
|
||||
pub fn seat_at_table() -> String {
|
||||
String::from("sit down please")
|
||||
}
|
||||
|
2
practices/hello-package/src/front_of_house/mod.rs
Normal file
2
practices/hello-package/src/front_of_house/mod.rs
Normal file
@ -0,0 +1,2 @@
|
||||
pub mod hosting;
|
||||
pub mod serving;
|
9
practices/hello-package/src/front_of_house/serving.rs
Normal file
9
practices/hello-package/src/front_of_house/serving.rs
Normal file
@ -0,0 +1,9 @@
|
||||
pub fn take_order() {}
|
||||
|
||||
pub fn serve_order() {}
|
||||
|
||||
pub fn take_payment() {}
|
||||
|
||||
// Maybe you don't want the guest hearing the your complaining about them
|
||||
// So just make it private
|
||||
fn complain() {}
|
12
practices/hello-package/src/lib.rs
Normal file
12
practices/hello-package/src/lib.rs
Normal file
@ -0,0 +1,12 @@
|
||||
mod front_of_house;
|
||||
mod back_of_house;
|
||||
|
||||
pub use crate::front_of_house::hosting;
|
||||
|
||||
pub fn eat_at_restaurant() -> String {
|
||||
front_of_house::hosting::add_to_waitlist();
|
||||
|
||||
back_of_house::cook_order();
|
||||
|
||||
String::from("yummy yummy!")
|
||||
}
|
4
practices/hello-package/src/main.rs
Normal file
4
practices/hello-package/src/main.rs
Normal file
@ -0,0 +1,4 @@
|
||||
fn main() {
|
||||
assert_eq!(hello_package::hosting::seat_at_table(), "sit down please");
|
||||
assert_eq!(hello_package::eat_at_restaurant(),"yummy yummy!");
|
||||
}
|
Reference in New Issue
Block a user