Created
March 29, 2018 13:28
-
-
Save thomwiggers/11ee947373c54faf14608070a6bc2837 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro_rules! implement_index { | |
($t: ty, $size: expr) => { | |
impl ops::Index<usize> for BitVector<$t> { | |
type Output = u8; | |
fn index(&self, index: usize) -> Self::Output { | |
let block_index = index / $size; | |
let remainder = index % $size; | |
(self.0[block_index] >> remainder) & 1 | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment