Hands-on Rust: Missing Vector Initialization in Enum Section of Chapter 2

Hey All,

In the last section of Chapter 2 talking about Enums we are missing an explanation on how to initialize the Vector entries with the new Enums. Particularly confusing is how to initialize an Enum with data

Grabbing it from the source code on the website makes it clear:

    let mut visitor_list = vec![
        Visitor::new("Bert", VisitorAction::Accept, 45),
        Visitor::new("Steve", VisitorAction::AcceptWithNote{ note: String::from("Lactose-free milk is in the fridge") }, 15),
        Visitor::new("Fred", VisitorAction::Refuse, 30),
    ];

Just a suggestion but a short bit on that in the enum section would be great!

3 Likes

A one-liner with respect to the trailing commas as convention might also be useful.

3 Likes

Thanks to both of you! I’ll include those in beta 2, they are now in my issue tracker.

2 Likes