Trait BitSetMut

Source
pub trait BitSetMut<T> {
    // Required methods
    fn clear(&mut self);
    fn insert(&mut self, _: T) -> Option<bool>;
    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) -> Option<bool>

Inserts the value into the set.

Returns 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(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<u32> for [u32]

Source§

fn clear(&mut self)

Source§

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

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) -> Option<bool>

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) -> Option<bool>

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) -> Option<bool>

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) -> Option<bool>

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) -> Option<bool>

Source§

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

Implementors§