Skip to content

Commit 0ddeb5e

Browse files
authored
Merge pull request #745 from king6cong/ref
reorganize docs on references
2 parents 09d5b03 + 4334f63 commit 0ddeb5e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/types/pointer.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
All pointers in Rust are explicit first-class values. They can be moved or
44
copied, stored into data structs, and returned from functions.
55

6-
## Shared references (`&`)
6+
## References (`&` and `&mut`)
77

88
> **<sup>Syntax</sup>**\
99
> _ReferenceType_ :\
1010
> &nbsp;&nbsp; `&` [_Lifetime_]<sup>?</sup> `mut`<sup>?</sup> [_TypeNoBounds_]
1111
12+
### Shared references (`&`)
13+
1214
These point to memory _owned by some other value_. When a shared reference to
1315
a value is created it prevents direct mutation of the value. [Interior
1416
mutability] provides an exception for this in certain circumstances. As the
@@ -19,7 +21,7 @@ only copying the pointer itself, that is, pointers are `Copy`. Releasing a
1921
reference has no effect on the value it points to, but referencing of a
2022
[temporary value] will keep it alive during the scope of the reference itself.
2123

22-
## Mutable references (`&mut`)
24+
### Mutable references (`&mut`)
2325

2426
These also point to memory owned by some other value. A mutable reference type
2527
is written `&mut type` or `&'a mut type`. A mutable reference (that hasn't been

0 commit comments

Comments
 (0)