memacc/bitman/unchecked/read/
are_bits_high_scattered.rs

1use crate::bitman::IsBitLow;
2
3/// Can check if multiple bits are high in non-continuous manner.
4pub trait AreBitsHighScattered {
5    /// My type.
6    type Type;
7
8    /// Check if multiple bits are high in non-continuous manner.
9    fn are_bits_high_scattered(&self, indices: &[Self::Type]) -> bool;
10}
11
12/// Implement [`AreBitsHighScattered`] for given type.
13macro_rules! ImplementAreBitsHighScattered {
14    ($type:ty) => {
15        impl AreBitsHighScattered for $type {
16            type Type = Self;
17            #[inline]
18            #[must_use]
19            fn are_bits_high_scattered(&self, indices: &[Self::Type]) -> bool {
20                for index in indices {
21                    if self.is_bit_low(*index) {
22                        return false;
23                    }
24                }
25                true
26            }
27        }
28    };
29}
30
31ImplementAreBitsHighScattered!(u8);
32ImplementAreBitsHighScattered!(u32);
33ImplementAreBitsHighScattered!(u64);
34
35// TODO: tests