File: Iter.md

package info (click to toggle)
rust-coreutils 0.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 505,620 kB
  • sloc: ansic: 103,594; asm: 28,570; sh: 8,910; python: 5,581; makefile: 472; cpp: 97; javascript: 72
file content (36 lines) | stat: -rw-r--r-- 983 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Shared Bit-Slice Iteration

This view iterates each bit in the bit-slice by [proxy reference][0]. It is
created by the [`BitSlice::iter`] method.

## Original

[`slice::Iter`](core::slice::Iter)

## API Differences

While this iterator can manifest `&bool` references, it instead yields the
`bitvec` [proxy reference][0] for consistency with the [`IterMut`] type. It can
be converted to yield true references with [`.by_refs()`]. Additionally, because
it does not yield `&bool`, the [`Iterator::copied`] method does not apply. It
can be converted to an iterator of `bool` values with [`.by_vals()`].

## Examples

```rust
use bitvec::prelude::*;

let bits = bits![0, 1];
for bit in bits.iter() {
  # #[cfg(feature = "std")] {
  println!("{}", bit);
  # }
}
```

[`BitSlice::iter`]: crate::slice::BitSlice::iter
[`IterMut`]: crate::slice::IterMut
[`Iterator::copied`]: core::iter::Iterator::copied
[`.by_refs()`]: Self::by_refs
[`.by_vals()`]: Self::by_vals
[0]: crate::ptr::BitRef