...

/

Searching with Iterators using Structs

Searching with Iterators using Structs

Learn about Rust's core concepts such as iterators and pattern matching in a struct.

Though visitors are now represented as structures, we still need to be able to search them. We could use the same search code as before, comparing your_name with visitor.name to call the greeting method directly, but this method isn’t ideal. This gets unwieldy as our visitors become more complicated and we add more visitors to the list.

[package]
name = "treehouse_guestlist_struct"
version = "0.1.0"
authors = ["Herbert Wolverson <herberticus@gmail.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
The treehouse_guestlist using Struct

Iterators

Rust provides a powerful feature known as iterators to manipulate data. Iterators can do a lot.

When working with lists of data, iterators are the first place to look for the functionality we need. Iterators are designed around function chaining. Each iterator step works as a building block to massage the data ...