Skip to main content

RcBitmask

Struct RcBitmask 

Source
pub struct RcBitmask { /* private fields */ }
Expand description

Compact reference count tracking using a bitmask. Supports up to 64 objects, each with a 1-bit “alive” flag.

Implementations§

Source§

impl RcBitmask

Source

pub fn new() -> Self

Create an empty bitmask (all dead).

Source

pub fn set_alive(&mut self, i: u32)

Mark slot i as alive (0 <= i < 64).

Source

pub fn set_dead(&mut self, i: u32)

Mark slot i as dead.

Source

pub fn is_alive(&self, i: u32) -> bool

Check if slot i is alive.

Source

pub fn alive_count(&self) -> u32

Count alive slots.

Source

pub fn dead_count(&self) -> u32

Count dead slots.

Source

pub fn first_dead(&self) -> Option<u32>

Find the first dead slot (for allocation).

Source

pub fn first_alive(&self) -> Option<u32>

Find the first alive slot.

Source

pub fn raw(&self) -> u64

Raw bitmask value.

Trait Implementations§

Source§

impl Default for RcBitmask

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for RcBitmask

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.