Skip to content

Commit b92eb82

Browse files
RalfJungHavvy
andauthored
Apply suggestions from code review
Co-authored-by: Ryan Scheel <[email protected]>
1 parent 9e02fd9 commit b92eb82

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/expressions/operator-expr.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ let a = & & & & mut 10;
7272

7373
### Raw address-of operators
7474

75-
Related to the borrow operators are the raw address-of operators, which do not have first-class syntax, but are exposed via the macros `ptr::addr_of!(expr)` and `ptr::addr_of_mut!(expr)`.
75+
Related to the borrow operators are the *raw address-of operators*, which do not have first-class syntax, but are exposed via the macros `ptr::addr_of!(expr)` and `ptr::addr_of_mut!(expr)`.
7676
Like with `&`/`&mut`, the expression is evaluated in place expression context.
7777
The difference is that `&`/`&mut` create *references* of type `&T`/`&mut T`, while `ptr::addr_of!(expr)` creates a (const) raw pointer of type `*const T` and `ptr::addr_of_mut!(expr)` creates a mutable raw pointer of type `*mut T`.
7878

79-
The raw address-of operators must be used whenever the place expression denotes a place that is not properly aligned or does not store a valid value as determined by its type.
79+
The raw address-of operators must be used whenever the place expression could evaluate to a place that is not properly aligned or does not store a valid value as determined by its type.
8080
In those situations, using a borrow operator would cause [undefined behavior] by creating an invalid reference, but a raw pointer may still be constructed using an address-of operator.
8181

82-
**Example of creating a raw pointer to an unaligned place (through a `packed` struct):**
82+
The following is an example of creating a raw pointer to an unaligned place through a `packed` struct:
8383

8484
```rust
8585
use std::ptr;
@@ -96,7 +96,7 @@ let raw_f2 = ptr::addr_of!(packed.f2);
9696
assert_eq!(unsafe { raw_f2.read_unaligned() }, 2);
9797
```
9898

99-
**Example of creating a raw pointer to a place that does not contain a valid value:**
99+
The following is an example of creating a raw pointer to a place that does not contain a valid value:
100100

101101
```rust
102102
use std::{ptr, mem::MaybeUninit};

0 commit comments

Comments
 (0)