From: Ralf Jung Date: Mon, 18 Jan 2016 09:04:49 +0000 (+0100) Subject: the official term is mutable references, be more explicit about that X-Git-Url: https://git.ralfj.de/rust-101.git/commitdiff_plain/38318e759c8aae48e68e413856289eb436a15b08?ds=sidebyside;hp=--cc the official term is mutable references, be more explicit about that --- 38318e759c8aae48e68e413856289eb436a15b08 diff --git a/src/part04.rs b/src/part04.rs index 754ba62..375ef9f 100644 --- a/src/part04.rs +++ b/src/part04.rs @@ -98,13 +98,13 @@ fn shared_ref_demo() { //@ that was created before calling `vec_min` remains valid. // ## Unique, mutable references -//@ There is a second way to borrow something, a second kind of reference: The *unique reference*. This is a reference that comes with the promise that -//@ nobody else has *any kind of access* to the referee - there is no aliasing. As a consequence, it is always safe to mutate data through -//@ an unique reference, which is why they are usually called *mutable references*. +//@ There is a second way to borrow something, a second kind of reference: The *mutable reference*. This is a reference that comes with the promise +//@ that nobody else has *any kind of access* to the referee - there is no aliasing. It is thus always safe to perform mutation through such a reference. +//@ Because there cannot be another reference to the same data, we could also call it a *unique* reference, but that is not their official name. //@ As an example, consider a function which increments every element of a vector by 1. //@ The type `&mut Vec` is the type of mutable references to `vec`. Because the reference is -//@ mutable, we can use a mutable iterator, providing mutable (unique) references to the elements. +//@ mutable, we can use a mutable iterator, providing mutable references to the elements. fn vec_inc(v: &mut Vec) { for e in v.iter_mut() { *e += 1;