diff options
| author | Michael Howell <michael@notriddle.com> | 2022-10-23 14:48:19 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-23 14:48:19 -0700 |
| commit | ae2b1f096f888b4a248665184cb11fe763012a50 (patch) | |
| tree | dc50e7a2019f1b7f8e746dee33a3c61b93905ed9 | |
| parent | 296700eec55946c6beb435f6644d658d8aae1593 (diff) | |
| parent | 560433ac868e584538efaafdef9108d94d5f682a (diff) | |
| download | rust-ae2b1f096f888b4a248665184cb11fe763012a50.tar.gz rust-ae2b1f096f888b4a248665184cb11fe763012a50.zip | |
Rollup merge of #103447 - ajtribick:maybe_uninit_doc_update, r=scottmcm
`MaybeUninit`: use `assume_init_drop()` in the partially initialized array example The `assume_init_drop()` method does the same thing as the pointer conversion, and makes the example more straightforward.
| -rw-r--r-- | library/core/src/mem/maybe_uninit.rs | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/library/core/src/mem/maybe_uninit.rs b/library/core/src/mem/maybe_uninit.rs index efad9a9391b..7757c95de9d 100644 --- a/library/core/src/mem/maybe_uninit.rs +++ b/library/core/src/mem/maybe_uninit.rs @@ -146,7 +146,6 @@ use crate::slice; /// /// ``` /// use std::mem::MaybeUninit; -/// use std::ptr; /// /// // Create an uninitialized array of `MaybeUninit`. The `assume_init` is /// // safe because the type we are claiming to have initialized here is a @@ -162,7 +161,7 @@ use crate::slice; /// /// // For each item in the array, drop if we allocated it. /// for elem in &mut data[0..data_len] { -/// unsafe { ptr::drop_in_place(elem.as_mut_ptr()); } +/// unsafe { elem.assume_init_drop(); } /// } /// ``` /// |
