[−][src]Module bitvec::bits
Permit use of Rust native types as bit collections.
This module exposes two traits, Bits and BitsMut, which function similarly
to the AsRef and AsMut traits in the standard library. These traits allow an
implementor to express the means by which it can be interpreted as a collection
of bits.
Trait coherence rules forbid the following blanket implementation:
ⓘThis example deliberately fails to compile
impl<C: Cursor, T: Bits> AsRef<BitSlice<C, T::Store>> for T { fn as_ref(&self) -> &BitSlice<C, T::Store> { Bits::bits(self) } } impl<C: Cursor, T: BitsMut> AsMut<BitSlice<C, T::Store>> for T { fn as_ref(&mut self) -> &mut BitSlice<C, T::Store> { BitsMut::bits_mut(self) } }
but it is correct in theory, and so all types which implement Bits should
implement AsRef<BitSlice>, and all types which implement BitsMut should
implement AsMut<BitSlice>.
Traits
| Bits | Allows a type to be used as a sequence of immutable bits. |
| BitsMut | Allows a type to be used as a sequence of mutable bits. |