pub trait BitCollection:
From<<Self as IntoIterator>::Item>
+ From<BitIter<Self>>
+ IntoIterator<IntoIter = BitIter<Self>>
+ FromIterator<<Self as IntoIterator>::Item>
+ Extend<<Self as IntoIterator>::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;
Show 25 methods
// Required methods
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;
// Provided methods
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 { ... }
}Expand description
A type that represents a collection of bits that can be iterated over.
Required Associated Constants§
Required Methods§
Sourcefn len(&self) -> usize
fn len(&self) -> usize
Returns the number of bits set in self.
If checking whether self has zero, one, or multiple bits set, use
quantity.
Sourcefn has_multiple(&self) -> bool
fn has_multiple(&self) -> bool
Returns whether self has multiple bits set.
Sourceunsafe fn lsb_unchecked(&self) -> Self::Item
unsafe fn lsb_unchecked(&self) -> Self::Item
Returns the least significant bit in self without checking whether
self is empty.
Sourceunsafe fn msb_unchecked(&self) -> Self::Item
unsafe fn msb_unchecked(&self) -> Self::Item
Returns the most significant bit in self without checking whether
self is empty.
Sourcefn remove_lsb(&mut self)
fn remove_lsb(&mut self)
Removes the least significant bit from self.
Sourcefn remove_msb(&mut self)
fn remove_msb(&mut self)
Removes the most significant bit from self.
Sourcefn pop_lsb(&mut self) -> Option<Self::Item>
fn pop_lsb(&mut self) -> Option<Self::Item>
Removes the least significant bit from self and returns it.
Provided Methods§
Sourcefn as_iter(&mut self) -> &mut BitIter<Self> ⓘ
fn as_iter(&mut self) -> &mut BitIter<Self> ⓘ
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);Sourcefn lsb(&self) -> Option<Self::Item>
fn lsb(&self) -> Option<Self::Item>
Returns the least significant bit in self if self is not empty.
Sourcefn msb(&self) -> Option<Self::Item>
fn msb(&self) -> Option<Self::Item>
Returns the most significant bit in self if self is not empty.
Sourcefn removing<T: Into<Self>>(self, other: T) -> Self
fn removing<T: Into<Self>>(self, other: T) -> Self
Returns the result of removing the value from self.
Sourcefn inserting<T: Into<Self>>(self, other: T) -> Self
fn inserting<T: Into<Self>>(self, other: T) -> Self
Returns the result of inserting the value into self.
Sourcefn toggling<T: Into<Self>>(self, other: T) -> Self
fn toggling<T: Into<Self>>(self, other: T) -> Self
Returns the result of toggling the bits of the value in self.
Sourcefn intersecting<T: Into<Self>>(self, other: T) -> Self
fn intersecting<T: Into<Self>>(self, other: T) -> Self
Returns the result of intersecting the bits of the value with self.
Sourcefn setting<T: Into<Self>>(self, other: T, condition: bool) -> Self
fn setting<T: Into<Self>>(self, other: T, condition: bool) -> Self
Returns the result of setting the bits of the value in self based on
condition.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.