@@ -10,15 +10,15 @@ To use `fasthash`, first add this to your `Cargo.toml`:
10
10
fasthash = " 0.2"
11
11
```
12
12
13
- When use ` fasthash ` 128bit supports in Rust 1.15 (beta) or early , we need enable ` i128 ` feature
13
+ When use ` fasthash ` 128bit supports in Rust 1.15 (beta) or earlier version , we need enable ` i128 ` feature.
14
14
15
15
``` toml
16
16
[dependencies .fasthash ]
17
17
version = " 0.2"
18
18
features = [" i128" , " sse42" ]
19
19
```
20
20
21
- Then, add this to your crate root:
21
+ Then, add this to your crate root
22
22
23
23
``` rust
24
24
extern crate fasthash;
@@ -32,7 +32,13 @@ And then, use hash function with module or hasher
32
32
let h = city :: hash64 (" hello world" );
33
33
```
34
34
35
+ Or work with ` std::hash::Hash `
36
+
35
37
``` rust
38
+ use std :: hash :: Hash ;
39
+
40
+ use fasthash :: MetroHasher ;
41
+
36
42
fn hash <T : Hash >(t : & T ) -> u64 {
37
43
let mut s = MetroHasher :: new ();
38
44
t . hash (& mut s );
@@ -42,7 +48,7 @@ fn hash<T: Hash>(t: &T) -> u64 {
42
48
hash (& " hello world" );
43
49
```
44
50
45
- It also cowork with ` HashMap ` or ` HashSet ` , act as a hash function
51
+ It also works with ` HashMap ` or ` HashSet ` , act as the hash function
46
52
47
53
``` rust
48
54
use std :: collections :: HashSet ;
@@ -56,7 +62,6 @@ set.insert(2);
56
62
Or use RandomState<CityHash64 > with a random seed.
57
63
58
64
``` rust
59
- use std :: hash :: {Hash , Hasher };
60
65
use std :: collections :: HashMap ;
61
66
62
67
use fasthash :: RandomState ;
@@ -75,8 +80,8 @@ assert_eq!(map[&37], "c");
75
80
76
81
# Goal
77
82
- High performance
78
- - Zero cost
79
- - Compatibility with libstd
83
+ - Zero cost binding
84
+ - Compatibility with libstd/libcollection
80
85
81
86
# Features
82
87
0 commit comments