1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
macro_rules! get_bit { ($field:expr, $bit:expr) => { ($field & (1 << $bit)) > 0 } } macro_rules! set_bit { ($field:expr, $bit:expr, $enabled:expr) => { if $enabled { $field |= 1 << $bit; } else { $field &= !(1 << $bit) } } } macro_rules! add_indexing { ($ty:ty, $output:ty) => { use core::ops::{Index, IndexMut}; impl Index<usize> for $ty { type Output = $output; fn index(&self, index: usize) -> &Self::Output { &self.entries[index] } } impl IndexMut<usize> for $ty { fn index_mut(&mut self, index: usize) -> &mut Self::Output { &mut self.entries[index] } } } }