diff options
| author | Daniel Henry-Mantilla <daniel.henry.mantilla@gmail.com> | 2019-11-03 21:53:21 +0100 |
|---|---|---|
| committer | Daniel Henry-Mantilla <daniel.henry.mantilla@gmail.com> | 2019-11-04 19:47:31 +0100 |
| commit | 67f2200f4a1836742a605dca551408db56976b69 (patch) | |
| tree | 262d55ec51ed4feec9806ae62c6c16241a2ff709 | |
| parent | d9087cb388c00ec9a53f7a3049afb2ce00ce56fa (diff) | |
| download | rust-67f2200f4a1836742a605dca551408db56976b69.tar.gz rust-67f2200f4a1836742a605dca551408db56976b69.zip | |
Minor style improvements
Co-Authored-By: Ralf Jung <post@ralfj.de>
| -rw-r--r-- | src/libcore/mem/maybe_uninit.rs | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/src/libcore/mem/maybe_uninit.rs b/src/libcore/mem/maybe_uninit.rs index d5893dd1d58..51ba260589f 100644 --- a/src/libcore/mem/maybe_uninit.rs +++ b/src/libcore/mem/maybe_uninit.rs @@ -527,19 +527,15 @@ impl<T> MaybeUninit<T> { /// /// ```rust /// #![feature(maybe_uninit_ref)] - /// use ::std::mem::MaybeUninit; + /// use std::mem::MaybeUninit; /// /// let mut x = MaybeUninit::<Vec<u32>>::uninit(); /// // Initialize `x`: /// unsafe { x.as_mut_ptr().write(vec![1, 2, 3]); } - /// /* The above line can also be done without unsafe: - /// x = MaybeUninit::new(vec![1, 2, 3]); // */ /// // Now that our `MaybeUninit<_>` is known to be initialized, it is okay to /// // create a shared reference to it: /// let x: &Vec<u32> = unsafe { - /// // # Safety - /// // - /// // - `x` has been initialized. + /// // Safety: `x` has been initialized. /// x.get_ref() /// }; /// assert_eq!(x, &vec![1, 2, 3]); @@ -594,27 +590,25 @@ impl<T> MaybeUninit<T> { /// /// ```rust /// #![feature(maybe_uninit_ref)] - /// use ::std::mem::MaybeUninit; + /// use std::mem::MaybeUninit; /// - /// # unsafe extern "C" fn initialize_buffer (buf: *mut [u8; 2048]) { *buf = [0; 2048] } + /// # unsafe extern "C" fn initialize_buffer(buf: *mut [u8; 2048]) { *buf = [0; 2048] } /// # #[cfg(FALSE)] /// extern "C" { /// /// Initializes *all* the bytes of the input buffer. - /// fn initialize_buffer (buf: *mut [u8; 2048]); + /// fn initialize_buffer(buf: *mut [u8; 2048]); /// } /// /// let mut buf = MaybeUninit::<[u8; 2048]>::uninit(); /// /// // Initialize `buf`: /// unsafe { initialize_buffer(buf.as_mut_ptr()); } - /// // Now we know that `buf` has been initialized; so we could `.assume_init()` it. + /// // Now we know that `buf` has been initialized, so we could `.assume_init()` it. /// // However, using `.assume_init()` may trigger a `memcpy` of the 2048 bytes. /// // To assert our buffer has been initialized without copying it, we upgrade /// // the `&mut MaybeUninit<[u8; 2048]>` to a `&mut [u8; 2048]`: /// let buf: &mut [u8; 2048] = unsafe { - /// // # Safety - /// // - /// // - `buf` has been initialized. + /// // Safety: `buf` has been initialized. /// buf.get_mut() /// }; /// |
