pub struct ThinBox<T>where
T: ?Sized,{ /* private fields */ }
🔬This is a nightly-only experimental API. (
thin_box
)Expand description
ThinBox.
A thin pointer for heap allocation, regardless of T.
§Examples
#![feature(thin_box)]
use std::boxed::ThinBox;
let five = ThinBox::new(5);
let thin_slice = ThinBox::<[i32]>::new_unsize([1, 2, 3, 4]);
use std::mem::{size_of, size_of_val};
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));
Implementations§
source§impl<T> ThinBox<T>
impl<T> ThinBox<T>
Trait Implementations§
source§impl<T> Error for ThinBox<T>
impl<T> Error for ThinBox<T>
source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
impl<T> Send for ThinBox<T>
ThinBox<T>
is Send
if T
is Send
because the data is owned.
impl<T> Sync for ThinBox<T>
ThinBox<T>
is Sync
if T
is Sync
because the data is owned.
Auto Trait Implementations§
impl<T: ?Sized> Freeze for ThinBox<T>
impl<T: ?Sized> RefUnwindSafe for ThinBox<T>where
T: RefUnwindSafe,
impl<T: ?Sized> Unpin for ThinBox<T>where
T: Unpin,
impl<T: ?Sized> UnwindSafe for ThinBox<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more