
Rust Unlocked (Ch 2): The Stack, The Heap, and the Golden Rule of Ownership
Chapter 2: The Rules of the Record (Data & Ownership) In Chapter 1, we learned how to write a single note. But as you start writing more, you need a way to keep your "Record Book" organized. To keep your notes from getting mixed up or lost, Rust has a few "Golden Rules" for how information is handled. 1. The "Full Stop" Rule (The Semicolon ;) In English, you end a sentence with a period so the reader knows you’re done talking. In Rust, you must end almost every instruction with a semicolon ( ; ) . Think of this as the Official Stamp . It tells the computer: _"This sentence is finished. Move to the next line." fn main () { let shares = 18 ; // ✅ Correct: The sentence is stamped and finished. let price = 341 ; // ✅ Correct. } Did you notice the // in the code above? This is called a Comment . • The "Invisible Note": Anything you write after // is ignored by the computer. • Why use it? It’s like writing a small note to yourself (or a teammate) to explain what the code is doing wit
Continue reading on Dev.to Beginners
Opens in a new tab




