Skip to content

Commit

Permalink
Rollup merge of #103447 - ajtribick:maybe_uninit_doc_update, r=scottmcm
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
notriddle committed Oct 23, 2022
2 parents 296700e + 560433a commit ae2b1f0
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions library/core/src/mem/maybe_uninit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(); }
/// }
/// ```
///
Expand Down

0 comments on commit ae2b1f0

Please sign in to comment.