Skip to main content

SizeTracker

Trait SizeTracker 

Source
pub trait SizeTracker: Clone {
    const INIT: Self;
    const IS_TRACKING: bool;

    // Required methods
    fn increment(&mut self);
    fn decrement(&mut self);
    fn get(&self) -> usize;
    fn set(&mut self, size: usize);
    fn swap(&mut self, other: &mut Self);
}
Expand description

Trait for tracking the size of the list.

Required Associated Constants§

Source

const INIT: Self

The initial value for the tracker.

Source

const IS_TRACKING: bool

True if this tracker actually tracks the size.

Required Methods§

Source

fn increment(&mut self)

Increments the size count.

Source

fn decrement(&mut self)

Decrements the size count.

Source

fn get(&self) -> usize

Returns the current size.

Source

fn set(&mut self, size: usize)

Sets the size count.

Source

fn swap(&mut self, other: &mut Self)

Swaps the size count with another tracker.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl SizeTracker for NonTrackingSize

Source§

const INIT: Self = NonTrackingSize

Source§

const IS_TRACKING: bool = false

Source§

impl SizeTracker for TrackingSize

Source§

const INIT: Self

Source§

const IS_TRACKING: bool = true