Skip to content

Commit b1ce619

Browse files
committedOct 5, 2020
Add missing examples for MaybeUninit
1 parent fadf025 commit b1ce619

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed
 

‎library/core/src/mem/maybe_uninit.rs

+16-2
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,14 @@ impl<T> MaybeUninit<T> {
246246
/// Note that dropping a `MaybeUninit<T>` will never call `T`'s drop code.
247247
/// It is your responsibility to make sure `T` gets dropped if it got initialized.
248248
///
249+
/// # Example
250+
///
251+
/// ```
252+
/// use std::mem::MaybeUninit;
253+
///
254+
/// let v: MaybeUninit<Vec<u8>> = MaybeUninit::new(vec![42]);
255+
/// ```
256+
///
249257
/// [`assume_init`]: MaybeUninit::assume_init
250258
#[stable(feature = "maybe_uninit", since = "1.36.0")]
251259
#[rustc_const_stable(feature = "const_maybe_uninit", since = "1.36.0")]
@@ -259,9 +267,15 @@ impl<T> MaybeUninit<T> {
259267
/// Note that dropping a `MaybeUninit<T>` will never call `T`'s drop code.
260268
/// It is your responsibility to make sure `T` gets dropped if it got initialized.
261269
///
262-
/// See the [type-level documentation][type] for some examples.
270+
/// See the [type-level documentation][MaybeUninit] for some examples.
263271
///
264-
/// [type]: union.MaybeUninit.html
272+
/// # Example
273+
///
274+
/// ```
275+
/// use std::mem::MaybeUninit;
276+
///
277+
/// let v: MaybeUninit<String> = MaybeUninit::uninit();
278+
/// ```
265279
#[stable(feature = "maybe_uninit", since = "1.36.0")]
266280
#[rustc_const_stable(feature = "const_maybe_uninit", since = "1.36.0")]
267281
#[inline(always)]

0 commit comments

Comments
 (0)
Please sign in to comment.