blob: 6eb8cb5817de203aa189584a691bf63e8e21943c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
mod front_of_house {
pub mod hosting {
pub fn add_to_waitlist() {}
fn seat_at_table() {}
}
mod serving {
fn take_order() {}
fn serve_order() {}
fn take_payment() {}
}
}
fn deliver_order() {}
mod back_of_house {
fn fix_incorrect_order() {
cook_order();
super::deliver_order();
}
fn cook_order() {}
pub struct Breakfast {
seasonal_fruits: String,
pub toast: String,
}
impl Breakfast {
pub fn summer(toast: &str) -> Self {
Self {
toast: String::from(toast),
seasonal_fruits: String::from("Peach"),
}
}
}
}
pub mod eat_at_restaurent {
// absolute
// crate::front_of_house::hosting::add_to_waitlist();
// relative
// front_of_house::hosting::add_to_waitlist();
let mut meal = back_of_house::Breakfast::summer("Rye");
meal.toast = String::from("Wheat");
println!("I'd like {} toast please.", meal.toast);
}
|