# Hands-on Rust: confused about loop / vector section (p36)

**URL:** <https://forum.devtalk.com/t/hands-on-rust-confused-about-loop-vector-section-p36/17293>\
**Category:** PragProg Customers\
**Tags:** question, book-hands-on-rust\
**Created:** [13 August 2021 23:00 UTC](https://forum.devtalk.com/t/hands-on-rust-confused-about-loop-vector-section-p36/17293 "2021-08-13T23:00:40Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![herbert](https://forum.devtalk.com/user_avatar/forum.devtalk.com/herbert/32/1233_2.png) [@herbert](https://forum.devtalk.com/u/herbert)\
**Post date:** [13 August 2021 23:45 UTC](https://forum.devtalk.com/t/hands-on-rust-confused-about-loop-vector-section-p36/17293/2 "2021-08-13T23:45:18Z")

</div>

Hi! Thanks for buying the book.

You can find all the source code in a zip file on the book’s PragProg page: [Hands-on Rust: Effective Learning through 2D Game Development and Play by Herbert Wolverson](https://pragprog.com/titles/hwrust/hands-on-rust/)

I’ve also packaged it up for easy browsing on Github: [GitHub - thebracket/HandsOnRust: The source code that accompanies Hands-on Rust: Effective Learning throug](https://github.com/thebracket/HandsOnRust)

The filenames in the blue/green bar at the top of code snippets point to the filename referred to by the code in that snippet. The one you’re looking for is [this file](https://github.com/thebracket/HandsOnRust/blob/main/FirstStepsWithRust/treehouse_guestlist_vector/src/main.rs).

The `main` function looks like this:

```rust
fn main() {
    let mut visitor_list = vec![
        Visitor::new("Bert", "Hello Bert, enjoy your treehouse."),
        Visitor::new("Steve", "Hi Steve. Your milk is in the fridge."),
        Visitor::new("Fred", "Wow, who invited Fred?"),
    ];

    loop {
        println!("Hello, what's your name? (Leave empty and press ENTER to quit)");
        let name = what_is_your_name();

        let known_visitor = visitor_list.iter().find(|visitor| visitor.name == name);
        match known_visitor {
            Some(visitor) => visitor.greet_visitor(),
            None => {
                if name.is_empty() { // (1)
                    break; // (2)
                } else {
                    println!("{} is not on the visitor list.", name);
                    visitor_list.push(Visitor::new(&name, "New friend"));
                }
            }
        }
    }

    println!("The final list of visitors:");
    println!("{:#?}", visitor_list);
}

```

Hope that helps!  
Herbert

---

_[View the full topic](https://forum.devtalk.com/t/hands-on-rust-confused-about-loop-vector-section-p36/17293)._
