Add modules/paths
parent
150788a46d
commit
91af5b4385
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "restaurant"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
@ -0,0 +1,49 @@
|
||||
mod front_of_house {
|
||||
pub mod hosting {
|
||||
fn add_to_waitlist() {
|
||||
println!("hello")
|
||||
}
|
||||
|
||||
pub fn seat_at_table() {
|
||||
add_to_waitlist();
|
||||
}
|
||||
}
|
||||
|
||||
mod serving {
|
||||
fn take_order() {}
|
||||
|
||||
fn serve_order() {}
|
||||
|
||||
fn take_payment() {}
|
||||
}
|
||||
}
|
||||
|
||||
mod back_of_house {
|
||||
pub enum Appetizer {
|
||||
Soup,
|
||||
Salad,
|
||||
}
|
||||
|
||||
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"),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 orderOne = back_of_house::Appetizer::Soup;
|
||||
let orderTwo = back_of_house::Appetizer::Salad;
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
use restaurant::eat_at_restaurant;
|
||||
|
||||
fn main() {
|
||||
eat_at_restaurant();
|
||||
}
|
Loading…
Reference in New Issue