10
References
References, &T, are primitives and the preferred pointer type in Rust.
A reference is a safe pointer to a value located somewhere in memory, whether the stack, heap, or static data area. You can access the value through the reference.
References are values themself. For that reason, references can even reference other references, as a value.
Actually, Rust has two types of pointers: safe pointers (references) and raw pointers, which are inherently unsafe. The safeness of a reference is enforced at compile time with the borrow checker, as part of the ownership model. However, raw pointers are outside the scope of the borrow checker. For this reason, references are preferred in Rust. Raw pointers are primarily used with interoperability ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access