Structs
Explore how to define and use structs in Rust, including regular, tuple, and unit-like structs. Understand instantiation with the new method and builder patterns to efficiently organize and manage data.
We'll cover the following...
We'll cover the following...
Structs are the foundation of dealing with data in Rust. Let’s do a quick review of the basics before we dive in deeper.
A quick review of structs
A structure is a named collection, defining a new type. A struct can take one of three forms.
- Regular structs:
struct Person {
name: String,
age: i8,
}
...