Trait BitSetMut

Source
pub trait BitSetMut<T> {
    // Required methods
    fn clear(&mut self);
    fn insert(&mut self, _: T) -> Result<bool, usize>;
    fn remove(&mut self, _: T) -> Option<bool>;
}
Expand description

A trait for a mutate values in a bit set.

Required Methods§

Source

fn clear(&mut self)

Clears the set

§Example
use index_set::{BitSet, BitSetMut};

let mut bitset: [u32; 4] = [0; 4];
bitset.insert(0);
assert!(!BitSet::is_empty(&bitset[..]));

bitset.clear();
assert!(BitSet::is_empty(&bitset[..]));
Source

fn insert(&mut self, _: T) -> Result<bool, usize>

Inserts the value into the set.

Returns Ok(true) if the value was already set. Returns Err(usize) if the set cannot hold the value, where usize is the index of the slot.

§Example
use index_set::{BitSet, BitSetMut};

let mut bitset: [u32; 4] = [0; 4];
bitset.insert(0);
assert_eq!(bitset.has(0), true);
Source

fn remove(&mut self, _: T) -> Option<bool>

Removes the value from the set

Returns Some(true) if the value was already set. Returns None if the set cannot hold the value.

§Example
use index_set::{BitSet, BitSetMut};

let mut bitset: [u32; 4] = [0; 4];
bitset.insert(42);
assert_eq!(bitset.has(42), true);

bitset.remove(42);
assert_eq!(bitset.has(42), false);

Implementations on Foreign Types§

Source§

impl BitSetMut<u16> for [u16]

Source§

fn clear(&mut self)

Source§

fn insert(&mut self, index: u16) -> Result<bool, usize>

Source§

fn remove(&mut self, index: u16) -> Option<bool>

Source§

impl BitSetMut<u32> for [u32]

Source§

fn clear(&mut self)

Source§

fn insert(&mut self, index: u32) -> Result<bool, usize>

Source§

fn remove(&mut self, index: u32) -> Option<bool>

Source§

impl BitSetMut<u64> for [u64]

Source§

fn clear(&mut self)

Source§

fn insert(&mut self, index: u64) -> Result<bool, usize>

Source§

fn remove(&mut self, index: u64) -> Option<bool>

Source§

impl BitSetMut<u128> for [u128]

Source§

fn clear(&mut self)

Source§

fn insert(&mut self, index: u128) -> Result<bool, usize>

Source§

fn remove(&mut self, index: u128) -> Option<bool>

Source§

impl BitSetMut<usize> for [usize]

Source§

fn clear(&mut self)

Source§

fn insert(&mut self, index: usize) -> Result<bool, usize>

Source§

fn remove(&mut self, index: usize) -> Option<bool>

Source§

impl<Set, T> BitSetMut<T> for &mut Set
where Set: BitSetMut<T> + ?Sized,

Source§

fn clear(&mut self)

Source§

fn insert(&mut self, index: T) -> Result<bool, usize>

Source§

fn remove(&mut self, index: T) -> Option<bool>

Source§

impl<Set, T> BitSetMut<T> for Box<Set>
where Set: BitSetMut<T> + ?Sized,

Source§

fn clear(&mut self)

Source§

fn insert(&mut self, index: T) -> Result<bool, usize>

Source§

fn remove(&mut self, index: T) -> Option<bool>

Source§

impl<T> BitSetMut<T> for Vec<T>
where T: Default + Clone, [T]: BitSetMut<T>,

Source§

fn clear(&mut self)

Source§

fn insert(&mut self, value: T) -> Result<bool, usize>

Source§

fn remove(&mut self, value: T) -> Option<bool>

Implementors§