From 4334f6317c2c63bba0165abe572c309382da2d39 Mon Sep 17 00:00:00 2001 From: king6cong Date: Thu, 6 Feb 2020 16:28:16 +0800 Subject: [PATCH] reorganize docs on references --- src/types/pointer.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/types/pointer.md b/src/types/pointer.md index 8ed3fa8b9..de97815d2 100644 --- a/src/types/pointer.md +++ b/src/types/pointer.md @@ -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`) > **Syntax**\ > _ReferenceType_ :\ >    `&` [_Lifetime_]? `mut`? [_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 @@ -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