Skip to content

Commit 68f7928

Browse files
committed
Auto merge of #27566 - rubymeow:master, r=steveklabnik
I got a bit confused reading the guide over why all of a sudden there was an asterisk in the code. I was explained what it was there for in the IRC, and I think it should added it to the docs to prevent any further confusion!
2 parents 11deb08 + d3e089f commit 68f7928

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/doc/trpl/references-and-borrowing.md

+4
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ This will print `6`. We make `y` a mutable reference to `x`, then add one to
125125
the thing `y` points at. You’ll notice that `x` had to be marked `mut` as well,
126126
if it wasn’t, we couldn’t take a mutable borrow to an immutable value.
127127

128+
You'll also notice we added an asterisk (`*`) in front of `y`, making it `*y`,
129+
this is because `y` is an `&mut` reference. You'll also need to use them for
130+
accessing the contents of a reference as well.
131+
128132
Otherwise, `&mut` references are just like references. There _is_ a large
129133
difference between the two, and how they interact, though. You can tell
130134
something is fishy in the above example, because we need that extra scope, with

0 commit comments

Comments
 (0)