Add unit tests and fix various bugs

This commit is contained in:
Wilson Lin 2020-07-10 20:40:33 +10:00
commit 9ffb7b1d98
9 changed files with 429 additions and 58 deletions

View file

@ -50,7 +50,10 @@ impl std::ops::Index<u8> for Lookup {
type Output = bool;
fn index(&self, c: u8) -> &Self::Output {
&self.table[c as usize]
// \`c\` is definitely below 256 so it's always safe to directly index table without checking.
unsafe {
self.table.get_unchecked(c as usize)
}
}
}