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
pub enum Ingredients
{
Potato,
Meat,
Fish,
Ships,
}
pub struct Dish <'a>
{
pub ingredients: Vec<Ingredients>,
pub chef: &'a Chef,
}
pub struct Chef
{
name: String,
age: i32,
dishes_made: i32,
}
impl Chef {
pub fn new(name: String, age: i32) -> Chef {
Chef{
name: name,
age: age,
dishes_made: 0,
}
}
pub fn make_dish<'a >(&'a mut self, ingredients: Vec<Ingredients>) -> Dish {
self.dishes_made += 1;
Dish {
ingredients: ingredients,
chef: self,
}
}
}