4 ms·
> There are two kinds of references in Rust, a shared reference (also known as a borrow) Is that really what they're called? It seems confusing to me: if it's
by endorphine 4y ago
> There are two kinds of references in Rust, a shared reference (also known as a borrow)
Is that really what they're called? It seems confusing to me: if it's shared (i.e. many people use it at the same time) how can it also be borrowed (i.e. one person has it)?
- steveklabnik 4y agoThere are multiple ways of referring to this stuff. * mutable/immutable (this is the way the book refers to it and used to be the 'official' terms but I don't know if they've changed that since I left, partially this is the name because you spell it "&mut".) * shared/exclusive (this is the name that some people wish we had called mutable/immutable, a very very long time ago thing called the "mutapocalypse.") Both sets are adjectives for "borrow." I agree with you that "shared borrow" can feel like a contradiction in terms. In general, they are duals of each other: it depends if you want to start from a place of "can I change this" or "who all has access to this," making each term more clear depending on the perspective you take.
- endorphine 4y agoThis clears things up, thanks.