pub struct ThinBox<T>where T: ?Sized,{ /* private fields */ }
thin_box
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));
Moves a type to the heap with its Metadata stored in the heap allocation instead of on the stack.
Metadata
#![feature(thin_box)] use std::boxed::ThinBox; let five = ThinBox::new(5);
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)?;
#![feature(thin_box)] use std::boxed::ThinBox; let thin_slice = ThinBox::<[i32]>::new_unsize([1, 2, 3, 4]);
error_generic_member_access
ThinBox<T> is Send if T is Send because the data is owned.
ThinBox<T>
Send
T
ThinBox<T> is Sync if T is Sync because the data is owned.
Sync
TypeId
self
Returns the argument unchanged.
Calls U::from(self).
U::from(self)
That is, this conversion is whatever the implementation of From<T> for U chooses to do.
From<T> for U
arbitrary_self_types
String