Skip to content

Commit

Permalink
Merge pull request rust-lang#745 from king6cong/ref
Browse files Browse the repository at this point in the history
reorganize docs on references
  • Loading branch information
ehuss authored Feb 6, 2020
2 parents 09d5b03 + 4334f63 commit 0ddeb5e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/types/pointer.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
All pointers in Rust are explicit first-class values. They can be moved or
copied, stored into data structs, and returned from functions.

## Shared references (`&`)
## References (`&` and `&mut`)

> **<sup>Syntax</sup>**\
> _ReferenceType_ :\
> &nbsp;&nbsp; `&` [_Lifetime_]<sup>?</sup> `mut`<sup>?</sup> [_TypeNoBounds_]
### Shared references (`&`)

These point to memory _owned by some other value_. When a shared reference to
a value is created it prevents direct mutation of the value. [Interior
mutability] provides an exception for this in certain circumstances. As the
Expand All @@ -19,7 +21,7 @@ only copying the pointer itself, that is, pointers are `Copy`. Releasing a
reference has no effect on the value it points to, but referencing of a
[temporary value] will keep it alive during the scope of the reference itself.

## Mutable references (`&mut`)
### Mutable references (`&mut`)

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

0 comments on commit 0ddeb5e

Please sign in to comment.