use std::{
iter::{Skip, Take},
slice,
};
mod bit_packed;
pub use self::bit_packed::*;
mod bit_unpacked;
pub use self::bit_unpacked::*;
pub type BitmapIter<'a> = Take<Skip<BitUnpacked<slice::Iter<'a, u8>, &'a u8>>>;
pub type BitmapIntoIter<I> = Take<Skip<BitUnpacked<I, u8>>>;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn bit_packing() {
let input = [false, true, false, true, false, true];
assert_eq!(
input
.iter()
.bit_packed()
.bit_unpacked()
.take(input.len())
.collect::<Vec<bool>>(),
input
);
}
#[test]
fn additional_bits() {
let input = [false, true];
assert_eq!(
input
.iter()
.bit_packed()
.bit_unpacked()
.collect::<Vec<bool>>(),
[false, true, false, false, false, false, false, false]
);
}
#[test]
fn all_bits() {
let input = [true, true, false, true, false, true, true, true];
assert_eq!(
input
.iter()
.bit_packed()
.bit_unpacked()
.collect::<Vec<bool>>(),
input
);
}
}