Struct rustc_std_workspace_alloc::boxed::ThinBox
source · pub struct ThinBox<T>where
T: ?Sized,{
ptr: WithOpaqueHeader,
_marker: PhantomData<T>,
}
🔬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));
Fields§
§ptr: WithOpaqueHeader
🔬This is a nightly-only experimental API. (
§thin_box
)_marker: PhantomData<T>
🔬This is a nightly-only experimental API. (
thin_box
)Implementations§
source§impl<Dyn> ThinBox<Dyn>where
Dyn: ?Sized,
impl<Dyn> ThinBox<Dyn>where Dyn: ?Sized,
sourcepub fn new_unsize<T>(value: T) -> ThinBox<Dyn>where
T: Unsize<Dyn>,
🔬This is a nightly-only experimental API. (thin_box
)
pub fn new_unsize<T>(value: T) -> ThinBox<Dyn>where T: Unsize<Dyn>,
thin_box
)impl<T> ThinBox<T>where T: ?Sized,
Trait Implementations§
source§impl<T> Error for ThinBox<T>where
T: Error + ?Sized,
impl<T> Error for ThinBox<T>where T: Error + ?Sized,
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
source§fn type_id(&self, _: Internal) -> TypeIdwhere
Self: 'static,
fn type_id(&self, _: Internal) -> TypeIdwhere Self: 'static,
🔬This is a nightly-only experimental API. (
error_type_id
)Gets the
TypeId
of self
.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>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.
Auto Trait Implementations§
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