Title: Hands-On Rust (Chapter 11:Randomly Selecting an Architect"
With this block of code, I was expecting some explanation as to why we switched from *Architect {}
to *Architect::new()
. Instead, I just got compile errors and it dawned on me that we haven’t added constructors to those structs. I changed back to {} and all is fine, but it looks like we missed where we were supposed to add constructors.
let mut architect: Box<dyn MapArchitect> = match rng.range(0, 3) {
0 => Box::new(DrunkardsWalkArchitect::new()),
1 => Box::new(RoomsArchitect::new()),
_ => Box::new(CellularAutomataArchitect::new()),
};