pub fn count_ones(&self) -> usize {
		match self.domain() {
			Domain::Enclave(elem) => elem.load_value().count_ones() as usize,
			Domain::Region { head, body, tail } => {
				head.map_or(0, |elem| elem.load_value().count_ones() as usize)
					+ body
						.iter()
						.map(BitStore::load_value)
						.map(|elem| elem.count_ones() as usize)
						.sum::<usize>() + tail
					.map_or(0, |elem| elem.load_value().count_ones() as usize)
			},
		}
	}
/// Counts the number of bits set to `1` in the bit-slice contents.
///
/// ## Examples
///
/// ```rust
/// use bitvec::prelude::*;
///
/// let bits = bits![1, 1, 0, 0];
/// assert_eq!(bits[.. 2].count_ones(), 2);
/// assert_eq!(bits[2 ..].count_ones(), 0);
/// assert_eq!(bits![].count_ones(), 0);
/// ```
Counts the number of bits set to `1` in the bit-slice contents.
Counts the number of bits set to ` 1 ` in the bit - slice contents .
pub fn count_ones(&self) -> usize {
		match self.domain() {
			Domain::Enclave(elem) => elem.load_value().count_ones() as usize,
			Domain::Region { head, body, tail } => {
				head.map_or(0, |elem| elem.load_value().count_ones() as usize)
					+ body
						.iter()
						.map(BitStore::load_value)
						.map(|elem| elem.count_ones() as usize)
						.sum::<usize>() + tail
					.map_or(0, |elem| elem.load_value().count_ones() as usize)
			},
		}
	}
pub fn count_ones ( & self ) -> usize { match self . domain ( ) { Domain :: Enclave ( elem ) => elem . load_value ( ) . count_ones ( ) as usize , Domain :: Region { head , body , tail } => { head . map_or ( 0 , | elem | elem . load_value ( ) . count_ones ( ) as usize ) + body . iter ( ) . map ( BitStore :: load_value ) . map ( | elem | elem . count_ones ( ) as usize ) . sum :: < usize > ( ) + tail . map_or ( 0 , | elem | elem . load_value ( ) . count_ones ( ) as usize ) } , } }
Counts the number of bits set to `1` in the bit-slice contents.
Counts the number of bits set to ` 1 ` in the bit - slice contents .
&self
&self
examples
```rust
use bitvec::prelude::*.


` ` ` rust use bitvec :: prelude :: * .