When we instantiate a struct in our code our program creates the associated field data side by side in memory.
We instantiate by specifying all field values within
StructName { ... }
.
Struct fields are accessed using a dot operator .
.
Memory details of our example:
String::from
creates a struct String
that is placed side
by side with the fields of SeaCreature in the stack. A String represents text that can be changed
and does this by:String
struct (More on this in future lessons)