summaryrefslogtreecommitdiff
path: root/src/util.rs
blob: b17e304af4c870d683507d2fd4084650851f0846 (plain)
1
2
3
4
5
6
7
pub fn read_big_endian(bytes: &[u8], bits: usize) -> usize {
    bytes
        .iter()
        .enumerate()
        .map(|(i, &b)| (b as usize) << (bits * (bytes.len() - 1 - i)))
        .sum()
}