Skip to content

Commit 436432f

Browse files
committed
update document
1 parent a2099a0 commit 436432f

File tree

1 file changed

+13
-26
lines changed

1 file changed

+13
-26
lines changed

README.md

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,26 @@
1-
# rust-fasthash [![travis build](https://travis-ci.org/flier/rust-fasthash.svg?branch=master)](https://travis-ci.org/flier/rust-fasthash) [![crate](https://img.shields.io/crates/v/fasthash.svg)](https://crates.io/crates/fasthash) [![docs](https://docs.rs/fasthash/badge.svg)](https://docs.rs/crate/fasthash/)
2-
A suite of non-cryptographic hash functions for Rust, base on a forked [smhasher](https://github.com/rurban/smhasher/).
1+
## rust-fasthash [![travis build](https://travis-ci.org/flier/rust-fasthash.svg?branch=master)](https://travis-ci.org/flier/rust-fasthash) [![crate](https://img.shields.io/crates/v/fasthash.svg)](https://crates.io/crates/fasthash) [![docs](https://docs.rs/fasthash/badge.svg)](https://docs.rs/crate/fasthash/)
2+
A suite of non-cryptographic hash functions for Rust, binding the [smhasher](https://github.com/rurban/smhasher/).
33

4-
# Usage
5-
6-
To use `fasthash`, first add this to your `Cargo.toml`:
4+
## Usage
75

86
```toml
97
[dependencies]
10-
fasthash = "0.3"
8+
fasthash = "0.4"
119
```
1210

13-
Then, add this to your crate root
11+
### `hash` and `hash_with_seed` function
1412

1513
```rust
1614
extern crate fasthash;
1715

1816
use fasthash::*;
19-
```
2017

21-
And then, use hash function with module or hasher
22-
23-
```rust
2418
let h = city::hash64("hello world");
19+
20+
let h = metro::hash64_with_seed("hello world", 123);
2521
```
2622

27-
Or work with `std::hash::Hash`
23+
### `std::hash::Hash`
2824

2925
```rust
3026
use std::hash::Hash;
@@ -40,7 +36,7 @@ fn hash<T: Hash>(t: &T) -> u64 {
4036
hash(&"hello world");
4137
```
4238

43-
It also works with `HashMap` or `HashSet`, act as the hash function
39+
### `HashMap` and `HashSet`
4440

4541
```rust
4642
use std::collections::HashSet;
@@ -51,7 +47,7 @@ let mut set = HashSet::with_hasher(SpookyHash128 {});
5147
set.insert(2);
5248
```
5349

54-
Or use RandomState<CityHash64> with a random seed.
50+
### `RandomState`
5551

5652
```rust
5753
use std::collections::HashMap;
@@ -70,12 +66,7 @@ assert_eq!(map.insert(37, "c"), Some("b"));
7066
assert_eq!(map[&37], "c");
7167
```
7268

73-
# Goal
74-
- High performance
75-
- Zero cost binding
76-
- Compatibility with libstd/libcollection
77-
78-
# Features
69+
## Hash Functions
7970

8071
- Modern Hash Functions
8172
- [x] [City Hash](https://github.com/google/cityhash)
@@ -91,12 +82,8 @@ assert_eq!(map[&37], "c");
9182
- [x] [Hasher](https://doc.rust-lang.org/std/hash/trait.Hasher.html)
9283
- [x] std::collections::{[HashMap](https://doc.rust-lang.org/std/collections/struct.HashMap.html), [HashSet](https://doc.rust-lang.org/std/collections/struct.HashSet.html)} with `RandomState`
9384

94-
# Performance
95-
96-
To bench the hash function, we need nighly rust
85+
## Benchmark
9786

9887
```bash
99-
$ cargo +nightly bench
88+
$ cargo bench
10089
```
101-
102-
Please check [smhasher](https://github.com/rurban/smhasher/tree/master/doc) reports for more details.

0 commit comments

Comments
 (0)