Hands-on Rust: Architects don't have constructors yet

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()),
        };
1 Like

Thanks! I’ve logged this one for the next beta. It looks like a slightly embarrassing one on my part; I have an uncommitted branch that added the constructors, and apparently it didn’t merge upstream. Sorry about that!

1 Like