pub struct TotalSize { /* private fields */ }Expand description
Represents the total space taken up by an instance of a variable, including heap allocations
Implementations§
Source§impl TotalSize
impl TotalSize
Sourcepub const fn new(
total_bytes: usize,
excess_bytes: usize,
shared_bytes: usize,
distinct_allocations: usize,
) -> Self
pub const fn new( total_bytes: usize, excess_bytes: usize, shared_bytes: usize, distinct_allocations: usize, ) -> Self
Creates a new TotalSize
Sourcepub const fn total_bytes(&self) -> usize
pub const fn total_bytes(&self) -> usize
Returns the total bytes allocated
Sourcepub const fn excess_bytes(&self) -> usize
pub const fn excess_bytes(&self) -> usize
Returns the excess bytes allocated, the unused portions of allocated memory
Returns the number of shared bytes, bytes that are shared behind things
like Arc or Rc
Sourcepub const fn distinct_allocations(&self) -> usize
pub const fn distinct_allocations(&self) -> usize
Returns the number of distinct allocations
For example, a Box<u32> contains one distinct allocation while a
Box<Box<u32>> contains two
Sourcepub const fn used_bytes(&self) -> usize
pub const fn used_bytes(&self) -> usize
Return the total used bytes, calculated by total_bytes - excess_bytes
Trait Implementations§
Source§impl AddAssign for TotalSize
impl AddAssign for TotalSize
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+= operation. Read moreSource§impl Ord for TotalSize
impl Ord for TotalSize
Source§impl PartialOrd for TotalSize
impl PartialOrd for TotalSize
Source§impl SizeOf for TotalSize
impl SizeOf for TotalSize
Source§fn size_of_children(&self, _context: &mut Context)
fn size_of_children(&self, _context: &mut Context)
Gets the size of all “children” owned by this value, not including the
size of the value itself. Read more
Source§fn size_of_with_context(&self, context: &mut Context)
fn size_of_with_context(&self, context: &mut Context)
Adds the size of the current value to the given
Context,
including both the size of the value itself and all of its childrenSource§impl SubAssign for TotalSize
impl SubAssign for TotalSize
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-= operation. Read moreimpl Copy for TotalSize
impl Eq for TotalSize
impl StructuralPartialEq for TotalSize
Auto Trait Implementations§
impl Freeze for TotalSize
impl RefUnwindSafe for TotalSize
impl Send for TotalSize
impl Sync for TotalSize
impl Unpin for TotalSize
impl UnwindSafe for TotalSize
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