pub fn toggle(&mut self, index: usize) -> bool {
        let (pos, bit) = (Bitset::pos(index), Bitset::bit(index));

        if (self.0[pos] & bit) == 0 {
            self.ensure_size(index);
            self.0[pos] |= bit;
            true
        } else {
            if self.0.len() > pos {
                self.0[pos] &= !bit;
                self.trim_after_removing_at(index);
            }
            false
        }
    }
/// Toggles the value of the bit at the given index and returns its new
/// value.
///
/// # Example
/// ```
/// # use tuplequery::tuple::bitset::Bitset;
/// let mut bitset = Bitset::new();
///
/// bitset.on(2);
///
/// assert_eq!(bitset.iter().collect::<Vec<_>>(), vec![2]);
///
/// bitset.toggle(1);
/// bitset.toggle(2);
///
/// assert_eq!(bitset.iter().collect::<Vec<_>>(), vec![1]);
/// ```
Toggles the value of the bit at the given index and returns its new
value.
Toggles the value of the bit at the given index and returns its new value .
pub fn toggle(&mut self, index: usize) -> bool {
        let (pos, bit) = (Bitset::pos(index), Bitset::bit(index));
        if (self.0[pos] & bit) == 0 {
            self.ensure_size(index);
            self.0[pos] |= bit;
            true
        } else {
            if self.0.len() > pos {
                self.0[pos] &= !bit;
                self.trim_after_removing_at(index);
            }
            false
        }
    }
pub fn toggle ( & mut self , index : usize ) -> bool { let ( pos , bit ) = ( Bitset :: pos ( index ) , Bitset :: bit ( index ) ) ; if ( self . 0 [ pos ] & bit ) == 0 { self . ensure_size ( index ) ; self . 0 [ pos ] |= bit ; true } else { if self . 0 . len ( ) > pos { self . 0 [ pos ] &= ! bit ; self . trim_after_removing_at ( index ) ; } false } }
Toggles the value of the bit at the given index and returns its new
value.
Toggles the value of the bit at the given index and returns its new value .
&mut self
index
usize
&mut self
index
usize
example
None
use tuplequery::tuple::bitset::bitset;
let mut bitset = Bitset::new().





bitset.toggle(1);
bitset.toggle(2).


let mut bitset = Bitset :: new () . bitset . toggle ( 1 ) ; bitset . toggle ( 2 ) .