mirror of
https://gitee.com/openharmony/third_party_rust_rust-fnv
synced 2025-02-21 13:42:42 +00:00
Update readme to Rust 1.7 hasher API
and bump recommended crate version.
This commit is contained in:
parent
33c91cf5b4
commit
cce30450c0
18
README.md
18
README.md
@ -33,7 +33,7 @@ To include this crate in your program, add the following to your `Cargo.toml`:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
fnv = "1.0.0"
|
||||
fnv = "1.0.2"
|
||||
```
|
||||
|
||||
|
||||
@ -44,13 +44,12 @@ must create a default instance of a `FnvHasher` state, then create a new
|
||||
map using this state with `HashMap::with_hash_state`. A full example:
|
||||
|
||||
```rust
|
||||
#![feature(hashmap_hasher)]
|
||||
use std::collections::HashMap;
|
||||
use std::collections::hash_state::DefaultState;
|
||||
use std::hash::BuildHasherDefault;
|
||||
use fnv::FnvHasher;
|
||||
|
||||
let fnv = DefaultState::<FnvHasher>::default();
|
||||
let mut map = HashMap::with_hash_state(fnv);
|
||||
let fnv = BuildHasherDefault::<FnvHasher>::default();
|
||||
let mut map = HashMap::with_hasher(fnv);
|
||||
map.insert(1, "one");
|
||||
map.insert(2, "two");
|
||||
```
|
||||
@ -62,17 +61,16 @@ The standard library’s `HashSet` can be configured to use the FNV hasher
|
||||
with the same mechanism.
|
||||
|
||||
```rust
|
||||
#![feature(hashmap_hasher)]
|
||||
use std::collections::HashSet;
|
||||
use std::collections::hash_state::DefaultState;
|
||||
use std::hash::BuildHasherDefault;
|
||||
use fnv::FnvHasher;
|
||||
|
||||
let fnv = DefaultState::<FnvHasher>::default();
|
||||
let mut set = HashSet::with_hash_state(fnv);
|
||||
let fnv = BuildHasherDefault::<FnvHasher>::default();
|
||||
let mut set = HashSet::with_hasher(fnv);
|
||||
set.insert(1);
|
||||
set.insert(2);
|
||||
```
|
||||
|
||||
[chongo]: http://www.isthe.com/chongo/tech/comp/fnv/index.html
|
||||
[faq]: https://www.rust-lang.org/faq.html#why-are-rusts-hashmaps-slow
|
||||
[graphs]: http://cglab.ca/~abeinges/blah/hash-rs/
|
||||
[graphs]: http://cglab.ca/~abeinges/blah/hash-rs/
|
||||
|
Loading…
x
Reference in New Issue
Block a user