pub const fn set_bits(
base: u64,
value: u64,
value_bits: u64,
value_shift: u64,
) -> u64Expand description
Sets the bits of value in base without clearing already set
bits.
§Parameters
base: Base value to alter.value: New value/bits to be set inbase.value_bits: Amount of bits ofvaluethat are relevant.value_shift: Position ofvalueinsidebase, starting from the right/LSB (0).
§Example
use bit_ops::bitops_u64::set_bits;
// props of a fictional interrupt controller
let delivery_mode = 0b111;
let delivery_mode_bits = 3;
let delivery_mode_shift = 3;
assert_eq!(
set_bits(
0,
delivery_mode,
delivery_mode_bits,
delivery_mode_shift,
),
0b11_1000
);§Panics
This function panics for overflowing shifts and bit positions that are outside the range of the underlying type.