pub struct ThinBox<T: ?Sized> { /* private fields */ }
🔬This is a nightly-only experimental API. (
thin_box
#92791)Expand description
ThinBox.
用于堆分配的瘦指针,与 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));
RunImplementations§
Trait Implementations§
source§impl<T: ?Sized + Error> Error for ThinBox<T>
impl<T: ?Sized + Error> Error for ThinBox<T>
impl<T: ?Sized + Send> Send for ThinBox<T>
如果 T
是 Send
,则 ThinBox<T>
是 Send
,因为数据是拥有所有权的。
impl<T: ?Sized + Sync> Sync for ThinBox<T>
如果 T
是 Sync
,则 ThinBox<T>
是 Sync
,因为数据是拥有所有权的。
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
从拥有的值中借用。 Read more