LCOV - code coverage report
Current view: top level - src/util - bit_manipulation.rs (source / functions) Hit Total Coverage
Test: lcov Lines: 12 12 100.0 %
Date: 2023-12-07 18:49:03 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //! Utility functions for binary bit manipulations.
       2             : 
       3             : /// Sets the bit index to the bit value of a u16 integer.
       4          64 : pub fn set_bit_16(val: u16, bit_idx: i32, bit_val: bool) -> u16 {
       5          64 :     if bit_val { val | (1 << bit_idx) } else { val & !(1 << bit_idx) }
       6          64 : }
       7             : 
       8             : /// Sets the bit index to the bit value of a u32 integer.
       9         128 : pub fn set_bit_32(val: u32, bit_idx: i32, bit_val: bool) -> u32 {
      10         128 :     if bit_val { val | (1 << bit_idx) } else { val & !(1 << bit_idx) }
      11         128 : }
      12             : 
      13             : /// Returns if the bit at the index is set if a u16 integer.
      14          32 : pub fn is_bit_set_16(val: u16, bit_idx: i32) -> bool {
      15          32 :     ((val >> bit_idx) & 1) != 0
      16          32 : }
      17             : 
      18             : /// Returns if the bit at the index is set if a u32 integer.
      19          64 : pub fn is_bit_set_32(val: u32, bit_idx: i32) -> bool {
      20          64 :     ((val >> bit_idx) & 1) != 0
      21          64 : }

Generated by: LCOV version 1.16