From the course: Rust for Java Developers
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
References - Rust Tutorial
From the course: Rust for Java Developers
References
- [Instructor] Now let's unravel an integral part of Rust's memory model, References. If you are coming from a Java background, you're used to references as they're fundamental to the language. There are two forms of references in Rust. An immutable reference, also known as a shared reference, is denoted with an ampersand preceding some type. Here I'm using T as a placeholder. These references provide read-only access to the underlying data. They are what is implied when you hear the term, "a borrow" in Rust. Secondly, there are mutable references. They are also not as unique references. They're denoted with an ampersand and an m-u-t or mut keyword. They allow you to modify or change the underlying data. Another way to express this is to say that they offer read-write access to the underlying data. You may encounter lifetime annotations. They appear in source code as tick A or single quote A, but the name is actually…