Skip to content

reorganize docs on references #745

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 6, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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