Struct ThinBox
pub struct ThinBox<T: ?Sized> { pub(in ::boxed::thin) ptr: WithOpaqueHeader, pub(in ::boxed::thin) _marker: PhantomData<T> }
ThinBox.
A thin pointer for heap allocation, regardless of T.
Examples
use ThinBox;
let five = new;
let thin_slice = new_unsize;
let size_of_ptr = const >;
assert_eq!;
assert_eq!;
Fields
ptr: WithOpaqueHeader_marker: PhantomData<T>
Implementations
impl<Dyn: ?Sized> ThinBox<Dyn>
fn new_unsize<T>(value: T) -> Self where T: Unsize<Dyn>,Moves a type to the heap with its
Metadatastored in the heap allocation instead of on the stack.Examples
use ThinBox; let thin_slice = new_unsize;
impl<T> ThinBox<T>
fn new(value: T) -> SelfMoves a type to the heap with its
Metadatastored in the heap allocation instead of on the stack.Examples
use ThinBox; let five = new;fn try_new(value: T) -> Result<Self, AllocError>Moves a type to the heap with its
Metadatastored in the heap allocation instead of on the stack. Returns an error if allocation fails, instead of aborting.Examples
use ThinBox; let five = try_new?; # Ok::
impl<T: ?Sized> ThinBox<T>
fn meta(&self) -> <T as Pointee>::Metadatafn data(&self) -> *mut u8fn with_header(&self) -> &WithHeader<<T as Pointee>::Metadata>
Trait Implementations
impl<T> From<T> for ThinBox<T>
fn from(value: T) -> Self
impl<T: ?Sized + Debug> Debug for ThinBox<T>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<T: ?Sized + Display> Display for ThinBox<T>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<T: ?Sized + Error> Error for ThinBox<T>
fn source(&self) -> Option<&dyn Error + 'static>
impl<T: ?Sized + Send> Send for ThinBox<T>
impl<T: ?Sized + Sync> Sync for ThinBox<T>
impl<T: ?Sized> Deref for ThinBox<T>
type Target = T;fn deref(&self) -> &T
impl<T: ?Sized> DerefMut for ThinBox<T>
fn deref_mut(&mut self) -> &mut T
impl<T: ?Sized> Drop for ThinBox<T>
fn drop(&mut self)
Auto Trait Implementations
impl<T> Freeze for ThinBox<T>
where
PhantomData<T>: Freeze,
T: ?Sized,
impl<T> RefUnwindSafe for ThinBox<T>
where
PhantomData<T>: RefUnwindSafe,
T: ?Sized,
impl<T> Unpin for ThinBox<T>
where
PhantomData<T>: Unpin,
T: ?Sized,
impl<T> UnsafeUnpin for ThinBox<T>
where
PhantomData<T>: UnsafeUnpin,
T: ?Sized,
impl<T> UnwindSafe for ThinBox<T>
where
PhantomData<T>: UnwindSafe,
T: ?Sized,
Blanket Implementations
impl<P, T> Receiver for ThinBox<T>
where
P: Deref<Target = T> + ?Sized,
T: ?Sized,
type Target = T;
impl<T> Any for ThinBox<T>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for ThinBox<T>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for ThinBox<T>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for ThinBox<T>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> From<never> for ThinBox<T>
fn from(t: never) -> T
impl<T> SizeHint for ThinBox<T>
where
T: ?Sized,
fn lower_bound(&self) -> usizefn upper_bound(&self) -> Option<usize>
impl<T> SizedTypeProperties for ThinBox<T>
impl<T> ToString for ThinBox<T>
where
T: Display + ?Sized,
fn to_string(&self) -> String
impl<T, U> Into<U> for ThinBox<T>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for ThinBox<T>
where
U: Into<T>,
type Error = Infallible;fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for ThinBox<T>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>