| 18 | } |
| 19 | |
| 20 | fn neighbor(self, direction: &str) -> Self { |
| 21 | match direction { |
| 22 | "left" => { |
| 23 | println!("changed to room {}", direction); |
| 24 | Room::new(vec!["knife", "bread", "butter"].into_iter()) |
| 25 | } |
| 26 | "north" => { |
| 27 | println!("changed to room {}", direction); |
| 28 | Room::new(&mut ["polar-bear", "ice", "snow"].into_iter()) |
| 29 | } |
| 30 | "right" | "front" | "back" => { |
| 31 | println!("No room to the {}", direction); |
| 32 | self |
| 33 | } |
| 34 | _ => { |
| 35 | println!("unknown direction {}", direction); |
| 36 | self |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | struct Character { |