You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/types/pointer.md
+28-27
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
# Pointer types
2
2
3
-
All pointers in Rust are explicit first-class values. They can be moved or
4
-
copied, stored into data structs, and returned from functions.
3
+
All pointers in Rust are explicit first-class values.
4
+
They can be moved or copied, stored into data structs, and returned from functions.
5
5
6
6
## References (`&` and `&mut`)
7
7
@@ -11,46 +11,47 @@ copied, stored into data structs, and returned from functions.
11
11
12
12
### Shared references (`&`)
13
13
14
-
These point to memory _owned by some other value_. When a shared reference to
15
-
a value is created it prevents direct mutation of the value. [Interior
16
-
mutability] provides an exception for this in certain circumstances. As the
17
-
name suggests, any number of shared references to a value may exist. A shared
18
-
reference type is written `&type`, or `&'a type` when you need to specify an
19
-
explicit lifetime. Copying a reference is a "shallow" operation: it involves
20
-
only copying the pointer itself, that is, pointers are `Copy`. Releasing a
21
-
reference has no effect on the value it points to, but referencing of a
22
-
[temporary value] will keep it alive during the scope of the reference itself.
14
+
These point to memory _owned by some other value_.
15
+
When a shared reference to a value is created it prevents direct mutation of the value.
16
+
[Interior mutability] provides an exception for this in certain circumstances.
17
+
As the name suggests, any number of shared references to a value may exist.
18
+
A shared reference type is written `&type`, or `&'a type` when you need to specify an explicit lifetime.
19
+
Copying a reference is a "shallow" operation:
20
+
it involves only copying the pointer itself, that is, pointers are `Copy`.
21
+
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.
23
22
24
23
### Mutable references (`&mut`)
25
24
26
-
These also point to memory owned by some other value. A mutable reference type
27
-
is written `&mut type` or `&'a mut type`. A mutable reference (that hasn't been
28
-
borrowed) is the only way to access the value it points to, so is not `Copy`.
25
+
These also point to memory owned by some other value.
26
+
A mutable reference type is written `&mut type` or `&'a mut type`.
27
+
A mutable reference (that hasn't been borrowed) is the only way to access the value it points to, so is not `Copy`.
0 commit comments