GitXplorerGitXplorer
f

rust-fasthash

public
139 stars
30 forks
12 issues

Commits

List of commits on branch master.
Unverified
cbb3e35c9c7f7a16563a2da9dd84752c37b287a8

handle empty CARGO_CFG_TARGET_FEATURE

fflier committed 3 years ago
Unverified
9bcb7d929db4a736ad2332fd9c50fe3af3f13957

use env:var to check target arch/feature

fflier committed 3 years ago
Unverified
a551a063ff733e323dd338c43fd20faf1b91c974

add -mvsx for powerpc

fflier committed 3 years ago
Unverified
4bc91ad0c7a6e68ef0b96383edf34a65381a8552

add cross-compile library

fflier committed 3 years ago
Unverified
549447d55ed2924d49803c773614724d6692ff61

fix lint warning

fflier committed 3 years ago
Unverified
5ae86ca21d722d0a0adcbe086e4614e807fd3f78

fix multi line issue

fflier committed 3 years ago

README

The README file for this repository.

rust-fasthash Continuous integration 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

First install cargo-criterion:

$ cargo install cargo-criterion

Then you can use it to run Criterion-rs benchmarks:

$ cargo criterion