Struct StackBitSet

Source
pub struct StackBitSet<const N: usize>
where [(); { _ }]: Sized,
{ /* private fields */ }
Expand description

BitSet with compile-time size. It does not require any allocation and is entirely stored on the stack.

The only field is an array of usize. Each element is stored in a bit

§Examples

use stack_bitset::StackBitSet;

let mut a: StackBitSet<42> = StackBitSet::new();
a.set(12).unwrap();
assert!(a.get(12).unwrap());

Implementations§

Source§

impl<const N: usize> StackBitSet<N>
where [(); { _ }]: Sized,

Source

pub fn new() -> Self

Create a new empty instance of the bitset

Source

pub fn iter(&self) -> StackBitSetIterator<'_, N>

Source

pub fn iter_limit(&self, limit: usize) -> StackBitSetIterator<'_, N>

Source

pub fn get(&self, idx: usize) -> Result<bool, StackBitSetError>

Returns whether the elements at index idx in the bitset is set

Source

pub fn set(&mut self, idx: usize) -> Result<(), StackBitSetError>

sets the elements at index idx in the bitset

Source

pub fn reset(&mut self, idx: usize) -> Result<(), StackBitSetError>

Resets the element at index idx in the bitset

Source§

impl<const N: usize> StackBitSet<N>
where [(); { _ }]: Sized,

Source

pub fn union<const M: usize>( &self, other: &StackBitSet<M>, ) -> StackBitSet<{ _ }>
where [(); { _ }]: Sized,

Source

pub fn intersection<const M: usize>( &self, other: &StackBitSet<M>, ) -> StackBitSet<{ _ }>
where [(); { _ }]: Sized,

Source

pub fn difference<const M: usize>( &self, other: &StackBitSet<M>, ) -> StackBitSet<{ _ }>
where [(); { _ }]: Sized,

Source

pub fn complement(&self) -> StackBitSet<N>

Source

pub fn is_subset<const M: usize>(&self, other: &StackBitSet<M>) -> bool
where [(); { _ }]: Sized,

Source

pub fn is_equal<const M: usize>(&self, other: &StackBitSet<M>) -> bool
where [(); { _ }]: Sized,

Source

pub fn is_superset<const M: usize>(&self, other: &StackBitSet<M>) -> bool
where [(); { _ }]: Sized,

Trait Implementations§

Source§

impl<const N: usize, const M: usize> Add<&StackBitSet<M>> for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

type Output = StackBitSet<{ const_min(N, M) }>

The resulting type after applying the + operator.
Source§

fn add(self, other: &StackBitSet<M>) -> Self::Output

Performs the + operation. Read more
Source§

impl<const N: usize> Add<f32> for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

type Output = StackBitSet<N>

The resulting type after applying the + operator.
Source§

fn add(self, other: f32) -> StackBitSet<N>

Performs the + operation. Read more
Source§

impl<const N: usize> Add<f64> for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

type Output = StackBitSet<N>

The resulting type after applying the + operator.
Source§

fn add(self, other: f64) -> StackBitSet<N>

Performs the + operation. Read more
Source§

impl<const N: usize> Add<i128> for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

type Output = StackBitSet<N>

The resulting type after applying the + operator.
Source§

fn add(self, other: i128) -> StackBitSet<N>

Performs the + operation. Read more
Source§

impl<const N: usize> Add<i16> for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

type Output = StackBitSet<N>

The resulting type after applying the + operator.
Source§

fn add(self, other: i16) -> StackBitSet<N>

Performs the + operation. Read more
Source§

impl<const N: usize> Add<i32> for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

type Output = StackBitSet<N>

The resulting type after applying the + operator.
Source§

fn add(self, other: i32) -> StackBitSet<N>

Performs the + operation. Read more
Source§

impl<const N: usize> Add<i64> for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

type Output = StackBitSet<N>

The resulting type after applying the + operator.
Source§

fn add(self, other: i64) -> StackBitSet<N>

Performs the + operation. Read more
Source§

impl<const N: usize> Add<i8> for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

type Output = StackBitSet<N>

The resulting type after applying the + operator.
Source§

fn add(self, other: i8) -> StackBitSet<N>

Performs the + operation. Read more
Source§

impl<const N: usize> Add<isize> for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

type Output = StackBitSet<N>

The resulting type after applying the + operator.
Source§

fn add(self, other: isize) -> StackBitSet<N>

Performs the + operation. Read more
Source§

impl<const N: usize> Add<u128> for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

type Output = StackBitSet<N>

The resulting type after applying the + operator.
Source§

fn add(self, other: u128) -> StackBitSet<N>

Performs the + operation. Read more
Source§

impl<const N: usize> Add<u16> for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

type Output = StackBitSet<N>

The resulting type after applying the + operator.
Source§

fn add(self, other: u16) -> StackBitSet<N>

Performs the + operation. Read more
Source§

impl<const N: usize> Add<u32> for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

type Output = StackBitSet<N>

The resulting type after applying the + operator.
Source§

fn add(self, other: u32) -> StackBitSet<N>

Performs the + operation. Read more
Source§

impl<const N: usize> Add<u64> for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

type Output = StackBitSet<N>

The resulting type after applying the + operator.
Source§

fn add(self, other: u64) -> StackBitSet<N>

Performs the + operation. Read more
Source§

impl<const N: usize> Add<u8> for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

type Output = StackBitSet<N>

The resulting type after applying the + operator.
Source§

fn add(self, other: u8) -> StackBitSet<N>

Performs the + operation. Read more
Source§

impl<const N: usize> Add<usize> for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

type Output = StackBitSet<N>

The resulting type after applying the + operator.
Source§

fn add(self, other: usize) -> StackBitSet<N>

Performs the + operation. Read more
Source§

impl<const N: usize> Clone for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

fn clone(&self) -> StackBitSet<N>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const N: usize> Debug for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<const N: usize> Default for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

fn default() -> Self

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

impl<const N: usize> Sub<f32> for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

type Output = StackBitSet<N>

The resulting type after applying the - operator.
Source§

fn sub(self, other: f32) -> StackBitSet<N>

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<f64> for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

type Output = StackBitSet<N>

The resulting type after applying the - operator.
Source§

fn sub(self, other: f64) -> StackBitSet<N>

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<i128> for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

type Output = StackBitSet<N>

The resulting type after applying the - operator.
Source§

fn sub(self, other: i128) -> StackBitSet<N>

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<i16> for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

type Output = StackBitSet<N>

The resulting type after applying the - operator.
Source§

fn sub(self, other: i16) -> StackBitSet<N>

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<i32> for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

type Output = StackBitSet<N>

The resulting type after applying the - operator.
Source§

fn sub(self, other: i32) -> StackBitSet<N>

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<i64> for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

type Output = StackBitSet<N>

The resulting type after applying the - operator.
Source§

fn sub(self, other: i64) -> StackBitSet<N>

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<i8> for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

type Output = StackBitSet<N>

The resulting type after applying the - operator.
Source§

fn sub(self, other: i8) -> StackBitSet<N>

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<isize> for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

type Output = StackBitSet<N>

The resulting type after applying the - operator.
Source§

fn sub(self, other: isize) -> StackBitSet<N>

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<u128> for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

type Output = StackBitSet<N>

The resulting type after applying the - operator.
Source§

fn sub(self, other: u128) -> StackBitSet<N>

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<u16> for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

type Output = StackBitSet<N>

The resulting type after applying the - operator.
Source§

fn sub(self, other: u16) -> StackBitSet<N>

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<u32> for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

type Output = StackBitSet<N>

The resulting type after applying the - operator.
Source§

fn sub(self, other: u32) -> StackBitSet<N>

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<u64> for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

type Output = StackBitSet<N>

The resulting type after applying the - operator.
Source§

fn sub(self, other: u64) -> StackBitSet<N>

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<u8> for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

type Output = StackBitSet<N>

The resulting type after applying the - operator.
Source§

fn sub(self, other: u8) -> StackBitSet<N>

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<usize> for StackBitSet<N>
where [(); { _ }]: Sized,

Source§

type Output = StackBitSet<N>

The resulting type after applying the - operator.
Source§

fn sub(self, other: usize) -> StackBitSet<N>

Performs the - operation. Read more
Source§

impl<const N: usize> Copy for StackBitSet<N>
where [(); { _ }]: Sized,

Auto Trait Implementations§

§

impl<const N: usize> Freeze for StackBitSet<N>
where [(); { _ }]: Sized,

§

impl<const N: usize> RefUnwindSafe for StackBitSet<N>
where [(); { _ }]: Sized,

§

impl<const N: usize> Send for StackBitSet<N>
where [(); { _ }]: Sized,

§

impl<const N: usize> Sync for StackBitSet<N>
where [(); { _ }]: Sized,

§

impl<const N: usize> Unpin for StackBitSet<N>
where [(); { _ }]: Sized,

§

impl<const N: usize> UnwindSafe for StackBitSet<N>
where [(); { _ }]: Sized,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.