I am trying to use the fasthash crate within a lazy_static context like as below
If I replace the
let mut map1=HashMap::with_capacity(50000);
things work. I am not able to understand where should the hashmap type be changed ?
lazy_static! {
static ref HASHMAP: HashMap<String,String> = {
let xxhash = RandomState::<xx::Hash64>::new();
let mut map1 = HashMap::with_capacity_and_hasher(50000, xxhash);
let filename = "xxx.txt";
let file = File::open(&filename).unwrap();
let mut reader = BufReader::new(file);
let mut line = String::new();
loop {
// populate the hashmap
}
map1
};
}
I get the following error
error[E0308]: mismatched types
|
| static ref HASHMAP: HashMap<String,String> = {
| ---------------------- expected HashMap<std::string::String, std::string::String> because of return type
...
| map1
| ^^^^ expected struct std::collections::hash_map::RandomState, found struct fasthash::RandomState
|
= note: expected struct HashMap<_, _, std::collections::hash_map::RandomState>
found struct HashMap<_, _, fasthash::RandomState<fasthash::xx::Hash64>>
error: aborting due to previous error
For more information about this error, try rustc --explain E0308.