Basic Color support
This commit is contained in:
@@ -12,17 +12,21 @@ impl BitRange {
|
||||
macro_rules! create_bit_functions {
|
||||
($type_val:ty) => {
|
||||
paste::item! {
|
||||
fn [< get_mask_ $type_val >](range: &BitRange) -> $type_val {
|
||||
const fn [< get_mask_ $type_val >](range: &BitRange) -> $type_val {
|
||||
(1 << range.len) - 1
|
||||
}
|
||||
|
||||
pub fn [< clear_value_ $type_val >](dst: $type_val, range: &BitRange) -> $type_val {
|
||||
pub const fn [< clear_value_ $type_val >](dst: $type_val, range: &BitRange) -> $type_val {
|
||||
dst & !([< get_mask_ $type_val >](range) << (range.start as $type_val))
|
||||
}
|
||||
|
||||
pub fn [< set_value_ $type_val >](dst: $type_val, value: $type_val, range: &BitRange) -> $type_val {
|
||||
pub const fn [< set_value_ $type_val >](dst: $type_val, value: $type_val, range: &BitRange) -> $type_val {
|
||||
[< clear_value_ $type_val >](dst, range) | ((value & [< get_mask_ $type_val >](range)) << range.start)
|
||||
}
|
||||
|
||||
pub const fn [< get_value_ $type_val >](src: $type_val, range: &BitRange) -> $type_val {
|
||||
(src & [< get_mask_ $type_val >](range)) >> range.start
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user