pub struct TotalSize { /* private fields */ }Expand description
Represents the total space taken up by an instance of a variable, including heap allocations
Implementations
sourceimpl 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
sourceimpl AddAssign<TotalSize> for TotalSize
impl AddAssign<TotalSize> for TotalSize
sourcefn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+= operation. Read moresourceimpl Ord for TotalSize
impl Ord for TotalSize
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialOrd<TotalSize> for TotalSize
impl PartialOrd<TotalSize> for TotalSize
sourcefn partial_cmp(&self, other: &TotalSize) -> Option<Ordering>
fn partial_cmp(&self, other: &TotalSize) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moresourceimpl SizeOf for TotalSizewhere
usize: SizeOf,
impl SizeOf for TotalSizewhere
usize: SizeOf,
sourcefn 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
sourcefn size_of_with_context(&self, context: &mut Context)
fn size_of_with_context(&self, context: &mut Context)
sourceimpl SubAssign<TotalSize> for TotalSize
impl SubAssign<TotalSize> for TotalSize
sourcefn 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 StructuralEq for TotalSize
impl StructuralPartialEq for TotalSize
Auto Trait Implementations
impl RefUnwindSafe for TotalSize
impl Send for TotalSize
impl Sync for TotalSize
impl Unpin for TotalSize
impl UnwindSafe for TotalSize
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more