Skip to content

Commit 39b8157

Browse files
RalfJungHavvy
authored andcommitted
Apply suggestions from code review
Co-authored-by: Ryan Scheel <[email protected]>
1 parent 797bb9f commit 39b8157

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
@@ -81,14 +81,14 @@ let a = & & & & mut 10;
8181

8282
### Raw address-of operators
8383

84-
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)`.
84+
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)`.
8585
Like with `&`/`&mut`, the expression is evaluated in place expression context.
8686
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`.
8787

88-
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.
88+
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.
8989
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.
9090

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

9393
```rust
9494
use std::ptr;
@@ -105,7 +105,7 @@ let raw_f2 = ptr::addr_of!(packed.f2);
105105
assert_eq!(unsafe { raw_f2.read_unaligned() }, 2);
106106
```
107107

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

110110
```rust
111111
use std::{ptr, mem::MaybeUninit};

0 commit comments

Comments
 (0)