Crates.io | wyhash2 |
lib.rs | wyhash2 |
version | 0.2.1 |
source | src |
created_at | 2021-02-19 12:49:58.777084 |
updated_at | 2021-05-23 17:39:22.416816 |
description | A simple wyhash2 implementation in rust. |
homepage | |
repository | https://github.com/JackThomson2/wyhash2 |
max_upload_size | |
id | 357553 |
size | 9,761 |
A simple, light and fast hashing algorithm written by Wang Yi. Ported to rust for your ease of use.
Thanks also goes to Eldruin their WyHash was very helpful for reference on getting started.
nightly
which enables some nightly only intrinsicts which can help improve performance.
std
This is enabled by default, however can be disabled for no_std
enviroments
A basic example:
use core::hash::Hasher;
use wyhash2::WyHash;
fn main() {
let secret = 0;
let mut hasher = WyHash::with_seed(secret);
hasher.write(&[0, 1, 2]);
println!("We got {}", hasher.finish());
}
Wyhash2 Implements BuildHasher which means it can be used as the hasher for the Hashmap
Usage with a Hashmap:
use wyhash2::WyHash;
use std::collections::HashMap;
fn main() {
let hasher = WyHash::with_seed(0);
let mut map: HashMap<String, String, WyHash> = HashMap::with_hasher(hasher);
map.insert("Hello".to_string(), "World".to_string());
println!("We got {}", map.get("Hello").unwrap());
}
[dependencies]
wyhash2 = { version = "...", default-features = false }
Licensed under either of
at your option.