I am new to Rust, and I am trying to write simple bitwise replacer.
I have this code:
const TABLE: [u64; 8] = [
0xC462A5B9E8D703F1,
0x68239A5
You can look at the documentation for SliceIndex
by searching the Rust standard library. The list of implementations of this trait at the bottom of the documentation page indicates that this trait is implemented for usize
and various usize
ranges.
This should answer both of your questions: indexing is not implemented for u8
type and you need to cast u8
to usize
.
(get_part(TABLE[left as usize], left) << 4) + get_part(TABLE[right as usize], right)