ombre 0.6.7

Shadowy game and graphics library for Rust
Documentation
//! Data containers used throughout the crate.

/// Hashet state used for collections.
pub type RandomState = std::hash::BuildHasherDefault<IntHasher>;
/// An integer map.
pub type IntMap<K, V> = std::collections::HashMap<K, V, RandomState>;
/// An integer set.
pub type IntSet = std::collections::HashSet<u32, RandomState>;

/// Integer hasher that doesn't do any hashing.
#[derive(Default, Copy, Clone)]
pub struct IntHasher {
    data: u64,
}

impl std::hash::Hasher for IntHasher {
    fn write(&mut self, _bytes: &[u8]) {
        panic!("IntHasher::write: invalid use: only integers are supported");
    }

    fn write_u8(&mut self, n: u8) {
        self.data = u64::from(n)
    }

    fn write_u16(&mut self, n: u16) {
        self.data = u64::from(n)
    }

    fn write_u32(&mut self, n: u32) {
        self.data = u64::from(n)
    }

    fn write_u64(&mut self, n: u64) {
        self.data = n
    }

    fn write_usize(&mut self, n: usize) {
        self.data = n as u64
    }

    fn write_i8(&mut self, n: i8) {
        self.data = n as u64
    }

    fn write_i16(&mut self, n: i16) {
        self.data = n as u64
    }

    fn write_i32(&mut self, n: i32) {
        self.data = n as u64
    }

    fn write_i64(&mut self, n: i64) {
        self.data = n as u64
    }

    fn write_isize(&mut self, n: isize) {
        self.data = n as u64
    }

    fn finish(&self) -> u64 {
        self.data
    }
}