diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2020-10-06 16:26:00 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-06 16:26:00 +0900 |
| commit | d7123c2393462447e30f62c8a785754677cc00da (patch) | |
| tree | 58694d203fbd57f20aadba51dd1764cb9c799d18 | |
| parent | d50349ba8d2baaa023eadacf7207516c83225f1f (diff) | |
| parent | b1ce6190ae4cb412c21207932924889e7201d4df (diff) | |
| download | rust-d7123c2393462447e30f62c8a785754677cc00da.tar.gz rust-d7123c2393462447e30f62c8a785754677cc00da.zip | |
Rollup merge of #77228 - GuillaumeGomez:maybeuninit-examples, r=pickfire
Add missing examples for MaybeUninit r? @Dylan-DPC
| -rw-r--r-- | library/core/src/mem/maybe_uninit.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/library/core/src/mem/maybe_uninit.rs b/library/core/src/mem/maybe_uninit.rs index e629d28eae1..862c452a434 100644 --- a/library/core/src/mem/maybe_uninit.rs +++ b/library/core/src/mem/maybe_uninit.rs @@ -246,6 +246,14 @@ impl<T> MaybeUninit<T> { /// Note that dropping a `MaybeUninit<T>` will never call `T`'s drop code. /// It is your responsibility to make sure `T` gets dropped if it got initialized. /// + /// # Example + /// + /// ``` + /// use std::mem::MaybeUninit; + /// + /// let v: MaybeUninit<Vec<u8>> = MaybeUninit::new(vec![42]); + /// ``` + /// /// [`assume_init`]: MaybeUninit::assume_init #[stable(feature = "maybe_uninit", since = "1.36.0")] #[rustc_const_stable(feature = "const_maybe_uninit", since = "1.36.0")] @@ -259,9 +267,15 @@ impl<T> MaybeUninit<T> { /// Note that dropping a `MaybeUninit<T>` will never call `T`'s drop code. /// It is your responsibility to make sure `T` gets dropped if it got initialized. /// - /// See the [type-level documentation][type] for some examples. + /// See the [type-level documentation][MaybeUninit] for some examples. /// - /// [type]: union.MaybeUninit.html + /// # Example + /// + /// ``` + /// use std::mem::MaybeUninit; + /// + /// let v: MaybeUninit<String> = MaybeUninit::uninit(); + /// ``` #[stable(feature = "maybe_uninit", since = "1.36.0")] #[rustc_const_stable(feature = "const_maybe_uninit", since = "1.36.0")] #[inline(always)] |
