Trait bit_collection::BitCollection [] [src]

pub trait BitCollection: From<Self::Item> + From<BitIter<Self>> + IntoIterator<IntoIter = BitIter<Self>> + FromIterator<Self::Item> + Extend<Self::Item> + Not<Output = Self> + BitAnd<Output = Self> + BitAndAssign + BitOr<Output = Self> + BitOrAssign + BitXor<Output = Self> + BitXorAssign + Sub<Output = Self> + SubAssign {
    const FULL: Self;
    const EMPTY: Self;

    fn len(&self) -> usize;
fn is_empty(&self) -> bool;
fn has_multiple(&self) -> bool;
unsafe fn lsb_unchecked(&self) -> Self::Item;
unsafe fn msb_unchecked(&self) -> Self::Item;
fn remove_lsb(&mut self);
fn remove_msb(&mut self);
fn pop_lsb(&mut self) -> Option<Self::Item>;
fn pop_msb(&mut self) -> Option<Self::Item>;
fn contains<T: Into<Self>>(&self, _: T) -> bool; fn quantity(&self) -> Quantity { ... }
fn as_iter(&mut self) -> &mut BitIter<Self> { ... }
fn into_bit(self) -> Option<Self::Item> { ... }
fn lsb(&self) -> Option<Self::Item> { ... }
fn msb(&self) -> Option<Self::Item> { ... }
fn removing<T: Into<Self>>(self, other: T) -> Self { ... }
fn inserting<T: Into<Self>>(self, other: T) -> Self { ... }
fn toggling<T: Into<Self>>(self, other: T) -> Self { ... }
fn intersecting<T: Into<Self>>(self, other: T) -> Self { ... }
fn setting<T: Into<Self>>(self, other: T, condition: bool) -> Self { ... }
fn remove<T: Into<Self>>(&mut self, other: T) -> &mut Self { ... }
fn insert<T: Into<Self>>(&mut self, other: T) -> &mut Self { ... }
fn toggle<T: Into<Self>>(&mut self, other: T) -> &mut Self { ... }
fn intersect<T: Into<Self>>(&mut self, other: T) -> &mut Self { ... }
fn set<T: Into<Self>>(&mut self, other: T, condition: bool) -> &mut Self { ... } }

A type that represents a collection of bits that can be iterated over.

Associated Constants

A full instance with all bits set.

An empty instance with no bits set.

Required Methods

Returns the number of bits set in self.

If checking whether self has zero, one, or multiple bits set, use quantity.

Returns whether self is empty.

Returns whether self has multiple bits set.

Returns the least significant bit in self without checking whether self is empty.

Returns the most significant bit in self without checking whether self is empty.

Removes the least significant bit from self.

Removes the most significant bit from self.

Removes the least significant bit from self and returns it.

Removes the most significant bit from self and returns it.

Returns whether self contains the value.

Provided Methods

Returns the quantity of bits set.

For an exact measurement of the number of bits set, use len.

This is much more optimal than matching len against 0, 1, and _.

Returns self as an iterator over itself.

Examples

This method is useful for partially iterating over a BitCollection in-place, and thus mutating it.

let mut rights = CastleRights::FULL;
assert_eq!(rights.len(), 4);

for right in rights.as_iter().take(3) { /* ... */ }
assert_eq!(rights.len(), 1);

Converts self into the only bit set.

Returns the least significant bit in self if self is not empty.

Returns the most significant bit in self if self is not empty.

Returns the result of removing the value from self.

Returns the result of inserting the value into self.

Returns the result of toggling the bits of the value in self.

Returns the result of intersecting the bits of the value with self.

Returns the result of setting the bits of the value in self based on condition.

Removes the value from self.

Inserts the value into self.

Toggles bits of the value in self.

Intersects the bits of the value with self.

Sets the bits of the value in self based on condition.

Implementors