Puzzle 14: Explanation
Let’s learn about how structured storage memory works in Rust.
We'll cover the following...
We'll cover the following...
Test it out
Hit “Run” to see the code’s output.
Explanation
Both _message_type and _destination occupy one and two bytes of memory. So, why does VeryImportantMessage occupy four bytes of memory?
By default, Rust makes these two promises about the in-memory representation of structures:
-
Structures may be differently sized than their contents for performance reasons.
-
Structures may internally store data in a different order than we specified if the optimizer ...