//! Utility functions for binary bit manipulations.
/// Sets the bit index to the bit value of a u16 integer.
pub fn set_bit_16(val: u16, bit_idx: i32, bit_val: bool) -> u16 {
if bit_val { val | (1 << bit_idx) } else { val & !(1 << bit_idx) }
}
/// Sets the bit index to the bit value of a u32 integer.
pub fn set_bit_32(val: u32, bit_idx: i32, bit_val: bool) -> u32 {
if bit_val { val | (1 << bit_idx) } else { val & !(1 << bit_idx) }
}
/// Returns if the bit at the index is set if a u16 integer.
pub fn is_bit_set_16(val: u16, bit_idx: i32) -> bool {
((val >> bit_idx) & 1) != 0
}
/// Returns if the bit at the index is set if a u32 integer.
pub fn is_bit_set_32(val: u32, bit_idx: i32) -> bool {
((val >> bit_idx) & 1) != 0
}