X-Git-Url: https://git.ralfj.de/rust-101.git/blobdiff_plain/375923e203d323dadc639434ebc1f29530f4ac2a..9960465b9f5be770af699b69e4ebd580d8e6a3e4:/src/part04.rs diff --git a/src/part04.rs b/src/part04.rs index faa3e31..2381ff4 100644 --- a/src/part04.rs +++ b/src/part04.rs @@ -101,11 +101,12 @@ fn shared_ref_demo() { //@ 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 - in contrast to shared references, there is no aliasing with mutable references. -//@ 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. +//@ 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 +//@ 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 references to the elements. fn vec_inc(v: &mut Vec) { for e in v.iter_mut() {