fasthash 0.2.2

A suite of non-cryptographic hash functions for Rust.
docs.rs failed to build fasthash-0.2.2
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: fasthash-0.4.0

A suite of non-cryptographic hash functions for Rust.

Example

use std::hash::{Hash, Hasher};

use fasthash::{metro, MetroHasher};

fn hash<T: Hash>(t: &T) -> u64 {
    let mut s: MetroHasher = Default::default();
    t.hash(&mut s);
    s.finish()
}

let h = metro::hash64(b"hello world\xff");

assert_eq!(h, hash(&"hello world"));

By default, HashMap uses a hashing algorithm selected to provide resistance against HashDoS attacks. The hashing algorithm can be replaced on a per-HashMap basis using the HashMap::with_hasher or HashMap::with_capacity_and_hasher methods.

It also cowork with HashMap or HashSet, act as a hash function

use std::collections::HashSet;

use fasthash::spooky::SpookyHash128;

let mut set = HashSet::with_hasher(SpookyHash128 {});
set.insert(2);

Or use RandomState with a random seed.

use std::hash::{Hash, Hasher};
use std::collections::HashMap;

use fasthash::RandomState;
use fasthash::city::CityHash64;

let s = RandomState::<CityHash64>::new();
let mut map = HashMap::with_hasher(s);

assert_eq!(map.insert(37, "a"), None);
assert_eq!(map.is_empty(), false);

map.insert(37, "b");
assert_eq!(map.insert(37, "c"), Some("b"));
assert_eq!(map[&37], "c");