Struct typesize::ptr::SizableArc
source · pub struct SizableArc<T, SC: ShouldCountInner>(pub Arc<T>, _);Expand description
A wrapper around Arc to implement TypeSize by allowing you to decide if to count the inner T’s size.
Examples
let arc = Arc::new(0);
let arc_borrow: SizableArc<u8, Borrowed> = arc.clone().into();
let arc_owner: SizableArc<u8, Owned> = arc.into();
// Just counts the pointer to the internal `ArcBox`.
assert_eq!(arc_borrow.get_size(), 0_usize.get_size());
// Counts the pointer to the `ArcBox`, plus the two AtomicUsize, and the value.
assert_eq!(arc_owner.get_size(), 0_usize.get_size() + (std::mem::size_of::<usize>() * 2) + 0_u8.get_size());Tuple Fields§
§0: Arc<T>Trait Implementations§
source§impl<T, SC: ShouldCountInner> Deref for SizableArc<T, SC>
impl<T, SC: ShouldCountInner> Deref for SizableArc<T, SC>
source§impl<T, SC: ShouldCountInner> From<Arc<T>> for SizableArc<T, SC>
impl<T, SC: ShouldCountInner> From<Arc<T>> for SizableArc<T, SC>
source§impl<T> TypeSize for SizableArc<T, Borrowed>
impl<T> TypeSize for SizableArc<T, Borrowed>
source§fn extra_size(&self) -> usize
fn extra_size(&self) -> usize
The number of bytes more than the
std::mem::size_of that this value is using.source§impl<T: TypeSize> TypeSize for SizableArc<T, Owned>
impl<T: TypeSize> TypeSize for SizableArc<T, Owned>
source§fn extra_size(&self) -> usize
fn extra_size(&self) -> usize
The number of bytes more than the
std::mem::size_of that this value is using.Auto Trait Implementations§
impl<T, SC> RefUnwindSafe for SizableArc<T, SC>where SC: RefUnwindSafe, T: RefUnwindSafe,
impl<T, SC> Send for SizableArc<T, SC>where SC: Send, T: Send + Sync,
impl<T, SC> Sync for SizableArc<T, SC>where SC: Sync, T: Send + Sync,
impl<T, SC> Unpin for SizableArc<T, SC>where SC: Unpin,
impl<T, SC> UnwindSafe for SizableArc<T, SC>where SC: UnwindSafe, T: RefUnwindSafe,
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