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
37
38
39
40
41
42
43
44
45
46
47
48
use super::{Fid, FidIter};
impl<'iter> Fid {
pub fn iter(&'iter self) -> FidIter<'iter> {
FidIter { fid: self, i: 0 }
}
}
impl<'iter> Iterator for FidIter<'iter> {
type Item = bool;
fn next(&mut self) -> Option<Self::Item> {
if self.i >= self.fid.len() {
None
} else {
self.i += 1;
Some(self.fid[self.i - 1])
}
}
}
#[cfg(test)]
mod iter_success_tests {
use crate::Fid;
#[test]
fn iter() {
let fid = Fid::from("1010_1010");
for (i, bit) in fid.iter().enumerate() {
assert_eq!(bit, fid[i as u64]);
}
}
}
#[cfg(test)]
mod iter_failure_tests {
}