What's In a Reference?
Explore how Rust uses references to point to values in memory. Understand the difference between mutable and immutable references, and learn best practices for using variables that hold references. This lesson clarifies Rust's conventions to effectively manage data access and mutability.
We'll cover the following...
We'll cover the following...
Every value in Rust lives somewhere in your computer’s memory. And every place in computer memory has an address. It’s possible to use println and the special {:p} syntax to display the address itself:
On my computer, this prints x == 5, located at 0x7ffeeb9b68f4. A reference can be thought of as a pointer; it’s an address pointing at a value that lives somewhere else. That’s also why we use the letter p in the format string ...