]> git.lizzy.rs Git - rust.git/commitdiff
MaybeUninit: use assume_init_drop() in the partially initialized array example
authorAndrew Tribick <ajtribick@googlemail.com>
Sun, 23 Oct 2022 16:59:24 +0000 (18:59 +0200)
committerAndrew Tribick <ajtribick@googlemail.com>
Sun, 23 Oct 2022 17:09:18 +0000 (19:09 +0200)
library/core/src/mem/maybe_uninit.rs

index efad9a9391b4c1713679a1360bf5cdee72a2b2c8..7757c95de9d2a27a9dcf9369a03825c0844561fa 100644 (file)
 ///
 /// ```
 /// 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
 ///
 /// // 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(); }
 /// }
 /// ```
 ///