@@ -186,14 +186,11 @@ With the `unsafe` block, we’re asserting to Rust that we’ve read the functio
186
186
documentation, we understand how to use it properly, and we’ve verified that
187
187
we’re fulfilling the contract of the function.
188
188
189
- > Note: In earlier versions of Rust, the body of an unsafe function was treated
190
- > as an ` unsafe ` block, so you could perform any unsafe operation within the
191
- > body of an ` unsafe ` function. In later versions of Rust, the compiler will
192
- > warn you that you need to use an ` unsafe ` block to perform unsafe operations
193
- > in the body of an unsafe function. This is because Rust now distinguishes
194
- > between ` unsafe fn ` , which defines what you need to do to call the function
195
- > safely, and an ` unsafe ` block, where you actually uphold that “contract” the
196
- > function establishes.
189
+ To perform unsafe operations in the body of an unsafe function, you still need
190
+ to use an ` unsafe ` block just as within a regular function, and the compiler
191
+ will warn you if you forget. This helps to keep ` unsafe ` blocks as small as
192
+ possible, as unsafe operations may not be needed across the whole function
193
+ body.
197
194
198
195
#### Creating a Safe Abstraction over Unsafe Code
199
196
@@ -550,5 +547,6 @@ Rust’s official guide to the subject, the [Rustonomicon][nomicon].
550
547
[the- slice- type ]: ch04- 03- slices. html#the- slice- type
551
548
[reference]: .. / reference/ items/ unions. html
552
549
[miri]: https: // github.com/rust-lang/miri
550
+ [editions]: appendix- 05- editions. html
553
551
[nightly]: appendix- 07- nightly- rust. html
554
552
[nomicon]: https: // doc.rust-lang.org/nomicon/
0 commit comments