pub struct ThinBox<T>where
T: ?Sized,{ /* private fields */ }
thin_box #92791)
ThinBox.
A thin pointer for heap allocation, regardless of T.
#![feature(thin_box)] use std::boxed::ThinBox; let five = ThinBox::new(5); let thin_slice = ThinBox::<[i32]>::new_unsize([1, 2, 3, 4]); let size_of_ptr = size_of::<*const ()>(); assert_eq!(size_of_ptr, size_of_val(&five)); assert_eq!(size_of_ptr, size_of_val(&thin_slice));
impl<T> ThinBox<T>
pub fn new(value: T) -> ThinBox<T>
thin_box #92791)
Moves a type to the heap with its Metadata stored in the heap allocation instead of on the stack.
#![feature(thin_box)] use std::boxed::ThinBox; let five = ThinBox::new(5);
pub fn try_new(value: T) -> Result<ThinBox<T>, AllocError>
thin_box #92791)
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.
#![feature(allocator_api)] #![feature(thin_box)] use std::boxed::ThinBox; let five = ThinBox::try_new(5)?;
impl<Dyn> ThinBox<Dyn>where
Dyn: ?Sized,pub fn new_unsize<T>(value: T) -> ThinBox<Dyn>where
T: Unsize<Dyn>,thin_box #92791)
Moves a type to the heap with its Metadata stored in the heap allocation instead of on the stack.
#![feature(thin_box)] use std::boxed::ThinBox; let thin_slice = ThinBox::<[i32]>::new_unsize([1, 2, 3, 4]);
impl<T> Debug for ThinBox<T>where
T: Debug + ?Sized,fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
impl<T> Deref for ThinBox<T>where
T: ?Sized,type Target = T
fn deref(&self) -> &T
impl<T> DerefMut for ThinBox<T>where
T: ?Sized,fn deref_mut(&mut self) -> &mut T
impl<T> Display for ThinBox<T>where
T: Display + ?Sized,fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
impl<T> Drop for ThinBox<T>where
T: ?Sized,impl<T> Error for ThinBox<T>where
T: Error + ?Sized,fn source(&self) -> Option<&(dyn Error + 'static)>
fn description(&self) -> &str
fn cause(&self) -> Option<&dyn Error>
fn provide<'a>(&'a self, request: &mut Request<'a>)
error_generic_member_access #99301)
impl<T> Send for ThinBox<T>where
T: Send + ?Sized,ThinBox<T> is Send if T is Send because the data is owned.
impl<T> Sync for ThinBox<T>where
T: Sync + ?Sized,ThinBox<T> is Sync if T is Sync because the data is owned.
impl<T> Freeze for ThinBox<T>where
T: ?Sized,impl<T> RefUnwindSafe for ThinBox<T>where
T: RefUnwindSafe + ?Sized,impl<T> Unpin for ThinBox<T>where
T: Unpin + ?Sized,impl<T> UnwindSafe for ThinBox<T>where
T: UnwindSafe + ?Sized,impl<T> Any for Twhere
T: 'static + ?Sized,impl<T> Borrow<T> for Twhere
T: ?Sized,impl<T> BorrowMut<T> for Twhere
T: ?Sized,impl<T> From<T> for T
fn from(t: T) -> T
Returns the argument unchanged.
impl<T, U> Into<U> for Twhere
U: From<T>,fn into(self) -> U
Calls U::from(self).
That is, this conversion is whatever the implementation of From<T> for U chooses to do.
impl<P, T> Receiver for Pwhere
P: Deref<Target = T> + ?Sized,
T: ?Sized,type Target = T
arbitrary_self_types #44874)
impl<T> ToString for Twhere
T: Display + ?Sized,impl<T, U> TryFrom<U> for Twhere
U: Into<T>,type Error = Infallible
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for Twhere
U: TryFrom<T>,
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/boxed/struct.ThinBox.html