Checks if the feature bit is set in the provided bitmap. Returns true if the `feature_bit` is set in the `bitmap`. Returns false if the `feature_bit` is unset or our ouf bounds. # Arguments `bitmap`: A slice of bytes representing the feature bitmap. `feature_bit`: The 0-based index of the bit to check across the bitmap.
(bitmap: &[u8], feature_bit: usize)
| 36 | /// * `feature_bit`: The 0-based index of the bit to check across the bitmap. |
| 37 | /// |
| 38 | pub fn is_feature_bit_set(bitmap: &[u8], feature_bit: usize) -> bool { |
| 39 | let byte_index = feature_bit >> 3; // Equivalent to feature_bit / 8 |
| 40 | let bit_index = feature_bit & 7; // Equivalent to feature_bit % 8 |
| 41 | |
| 42 | if let Some(&target_byte) = bitmap.get(byte_index) { |
| 43 | let mask = 1 << bit_index; |
| 44 | (target_byte & mask) != 0 |
| 45 | } else { |
| 46 | false |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | /// Returns a single feature_bit in hex representation, least-significant bit |
| 51 | /// first. |
no test coverage detected