fas
fasthash
cargo install fasthash
fas

fasthash

A suite of non-cryptographic hash functions for Rust.

by Flier Lu

0.4.0 (see all)License:Apache-2.0
cargo install fasthash
Readme

rust-fasthash travis build crate docs

A suite of non-cryptographic hash functions for Rust, binding the smhasher.

Usage

[dependencies]
fasthash = "0.4"

hash and hash_with_seed function

use fasthash::*;

let h = city::hash64("hello world");

let h = metro::hash64_with_seed("hello world", 123);

std::hash::Hash

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

use fasthash::{MetroHasher, FastHasher};

fn hash<T: Hash>(t: &T) -> u64 {
    // Or use any of the `*Hasher` struct's available as aliases from
    // root or in their respective modules as Hasher32/64 and some 128.
    let mut s = MetroHasher::default();
    t.hash(&mut s);
    s.finish()
}

hash(&"hello world");

HashMap and HashSet

use std::collections::HashSet;

use fasthash::spooky::Hash128;

let mut set = HashSet::with_hasher(Hash128);

set.insert(2);

RandomState

use std::collections::HashMap;

use fasthash::RandomState;
use fasthash::city::Hash64;

let s = RandomState::<Hash64>::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");

Hash Functions

Benchmark

$ cargo bench

GitHub Stars

85

LAST COMMIT

10mos ago

MAINTAINERS

1

CONTRIBUTORS

8

OPEN ISSUES

4

OPEN PRs

1
VersionTagPublished
0.4.0
3yrs ago
0.3.2
4yrs ago
0.3.1
4yrs ago
0.3.0
4yrs ago
No alternatives found
No tutorials found
Add a tutorial