@@ -527,19 +527,15 @@ impl<T> MaybeUninit<T> {
527
527
///
528
528
/// ```rust
529
529
/// #![feature(maybe_uninit_ref)]
530
- /// use :: std::mem::MaybeUninit;
530
+ /// use std::mem::MaybeUninit;
531
531
///
532
532
/// let mut x = MaybeUninit::<Vec<u32>>::uninit();
533
533
/// // Initialize `x`:
534
534
/// unsafe { x.as_mut_ptr().write(vec![1, 2, 3]); }
535
- /// /* The above line can also be done without unsafe:
536
- /// x = MaybeUninit::new(vec![1, 2, 3]); // */
537
535
/// // Now that our `MaybeUninit<_>` is known to be initialized, it is okay to
538
536
/// // create a shared reference to it:
539
537
/// let x: &Vec<u32> = unsafe {
540
- /// // # Safety
541
- /// //
542
- /// // - `x` has been initialized.
538
+ /// // Safety: `x` has been initialized.
543
539
/// x.get_ref()
544
540
/// };
545
541
/// assert_eq!(x, &vec![1, 2, 3]);
@@ -594,27 +590,25 @@ impl<T> MaybeUninit<T> {
594
590
///
595
591
/// ```rust
596
592
/// #![feature(maybe_uninit_ref)]
597
- /// use :: std::mem::MaybeUninit;
593
+ /// use std::mem::MaybeUninit;
598
594
///
599
- /// # unsafe extern "C" fn initialize_buffer (buf: *mut [u8; 2048]) { *buf = [0; 2048] }
595
+ /// # unsafe extern "C" fn initialize_buffer(buf: *mut [u8; 2048]) { *buf = [0; 2048] }
600
596
/// # #[cfg(FALSE)]
601
597
/// extern "C" {
602
598
/// /// Initializes *all* the bytes of the input buffer.
603
- /// fn initialize_buffer (buf: *mut [u8; 2048]);
599
+ /// fn initialize_buffer(buf: *mut [u8; 2048]);
604
600
/// }
605
601
///
606
602
/// let mut buf = MaybeUninit::<[u8; 2048]>::uninit();
607
603
///
608
604
/// // Initialize `buf`:
609
605
/// unsafe { initialize_buffer(buf.as_mut_ptr()); }
610
- /// // Now we know that `buf` has been initialized; so we could `.assume_init()` it.
606
+ /// // Now we know that `buf` has been initialized, so we could `.assume_init()` it.
611
607
/// // However, using `.assume_init()` may trigger a `memcpy` of the 2048 bytes.
612
608
/// // To assert our buffer has been initialized without copying it, we upgrade
613
609
/// // the `&mut MaybeUninit<[u8; 2048]>` to a `&mut [u8; 2048]`:
614
610
/// let buf: &mut [u8; 2048] = unsafe {
615
- /// // # Safety
616
- /// //
617
- /// // - `buf` has been initialized.
611
+ /// // Safety: `buf` has been initialized.
618
612
/// buf.get_mut()
619
613
/// };
620
614
///
0 commit comments