Tour of Rust Table of Contents

Creating Data In Memory

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:

  1. Creating memory on the heap for the text where it can be modified
  2. Storing a reference to that memory location on the heap and storing it in String struct (More on this in future lessons)