Skip to content

Commit

Permalink
Address ThinBox::try_new PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Feb 11, 2024
1 parent 3c880f2 commit ea6944a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions library/alloc/src/boxed/thin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,19 @@ impl<T> ThinBox<T> {
let ptr = WithOpaqueHeader::new(meta, value);
ThinBox { ptr, _marker: PhantomData }
}
}

#[unstable(feature = "thin_box", issue = "92791")]
impl<T> ThinBox<T> {
/// Moves a type to the heap with its [`Metadata`] stored in the heap allocation instead of on
/// the stack. Returns an error if allocation fails, instead of aborting.
///
/// # Examples
///
/// ```
/// #![feature(allocator_api)]
/// #![feature(thin_box)]
/// use std::boxed::ThinBox;
///
/// let five = ThinBox::new(5);
/// let five = ThinBox::try_new(5)?;
/// # Ok::<(), std::alloc::AllocError>(())
/// ```
///
/// [`Metadata`]: core::ptr::Pointee::Metadata
Expand Down

0 comments on commit ea6944a

Please sign in to comment.