about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndrew Tribick <ajtribick@googlemail.com>2022-10-23 18:59:24 +0200
committerAndrew Tribick <ajtribick@googlemail.com>2022-10-23 19:09:18 +0200
commit560433ac868e584538efaafdef9108d94d5f682a (patch)
treee75b34b9a1651c49ec927fd0b456d7f932039ca5
parent9be2f35a4c1ed1b04aa4a6945b64763f599259ff (diff)
MaybeUninit: use assume_init_drop() in the partially initialized array example
-rw-r--r--library/core/src/mem/maybe_uninit.rs3
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(); }
 /// }
 /// ```
 ///