Skip to content

Commit 1a47a50

Browse files
committed
feat: module example
1 parent 3253d5d commit 1a47a50

File tree

7 files changed

+64
-1
lines changed

7 files changed

+64
-1
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pub fn foo() {}
1+
pub mod restaurant;

src/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
use rust_template::restaurant;
2+
13
fn main() -> Result<(), Box<dyn std::error::Error>> {
4+
println!("Welcome at {}", restaurant::display_name());
5+
restaurant::foh::process_visit();
26
Ok(())
37
}

src/restaurant/boh/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
pub fn fix_incorrect_order() {
2+
println!("Fix incorrect order:");
3+
cook_order();
4+
super::deliver_order();
5+
}
6+
7+
pub fn cook_order() {
8+
println!("Cook order");
9+
}

src/restaurant/foh/hosting/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
pub fn add_to_wait_list() {
2+
println!("Add to wait list");
3+
}
4+
5+
pub fn seat_at_table() {
6+
println!("Seat at table");
7+
}
8+
9+
pub fn welcome() {}

src/restaurant/foh/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
pub mod hosting;
2+
pub mod serving;
3+
4+
pub fn process_visit() {
5+
hosting::welcome();
6+
hosting::add_to_wait_list();
7+
hosting::seat_at_table();
8+
serving::take_order();
9+
serving::serve_order();
10+
super::boh::cook_order();
11+
serving::take_complaint();
12+
super::boh::fix_incorrect_order();
13+
serving::take_payment();
14+
}

src/restaurant/foh/serving/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use crate::restaurant;
2+
3+
pub fn take_order() {
4+
println!("Take order");
5+
}
6+
7+
pub fn serve_order() {
8+
println!("Serve order");
9+
}
10+
11+
pub fn take_payment() {
12+
println!("Thanks for your visit at {}", restaurant::display_name());
13+
}
14+
15+
pub fn take_complaint() {
16+
println!("Take complaint");
17+
}

src/restaurant/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
pub fn display_name() -> &'static str {
2+
"Greek restaurant"
3+
}
4+
5+
fn deliver_order() {
6+
println!("Deliver order");
7+
}
8+
9+
pub mod boh;
10+
pub mod foh;

0 commit comments

Comments
 (0)