Google News
logo
Rust - Interview Questions
What are the types of references in Rust?
There are two types of references in Rust: immutable references and mutable references.

Immutable references : These are read-only references that allow you to borrow an immutable view of a value. When you have an immutable reference to a value, you cannot mutate the value through that reference. Immutable references are created using the & symbol followed by the value you want to borrow.

Mutable references : These are references that allow you to borrow a mutable view of a value. When you have a mutable reference to a value, you can mutate the value through that reference. Mutable references are created using the &mut keyword followed by the value you want to borrow.
Advertisement