title: How can I use a custom hash function in a HashSet or HashMap?
body: <p>Since SipHasher is too slow for my use case, I'm trying to implement a custom hash function. I found <a href="https://github.com/rust-lang/rust/blob/master/src/librustc/util/nodemap.rs" rel="nofollow">an example</a> which I used as base to get everything compiling.</p>
  
  <p>My current code looks like this:</p>
  
  <pre><code>use std::collections::hash_state::{DefaultState};
  use std::collections::{HashMap, HashSet};
  use std::default::Default;
  use std::hash::{Hash, Hasher, SipHasher};
  use std::marker;
  
  pub struct FnvHasher(u64);
  
  impl Default for FnvHasher {
      fn default() -&gt; FnvHasher { FnvHasher(0xcbf29ce484222325) }
  }
  
  impl Hasher for FnvHasher {
      fn write(&amp;mut self, bytes: &amp;[u8]) {
          let FnvHasher(mut hash) = *self;
          for byte in bytes {
              hash = hash ^ (*byte as u64);
              hash = hash * 0x100000001b3;
          }
          *self = FnvHasher(hash);
      }
      fn finish(&amp;self) -&gt; u64 { self.0 }
  }
  
  fn main() {
      let mut set:HashSet&lt;i64, DefaultState&lt;FnvHasher&gt;&gt; = HashSet::with_hash_state(DefaultState::&lt;FnvHasher&gt;);
  }
  </code></pre>
  
  <p>When I compile I get the following error message:</p>
  
  <pre><code>$ rustc -V
  rustc 1.0.0-nightly (522d09dfe 2015-02-19) (built 2015-02-19)
  
  $ rustc hash.rs
  hash.rs:26:86: 26:111 error: mismatched types:
   expected `std::collections::hash::state::DefaultState&lt;FnvHasher&gt;`,
      found `fn(core::marker::PhantomData&lt;FnvHasher&gt;) -&gt; std::collections::hash::state::DefaultState&lt;FnvHasher&gt; {std::collections::hash::state::DefaultState}`
  (expected struct `std::collections::hash::state::DefaultState`,
      found fn item) [E0308]
  hash.rs:26         let mut set:HashSet&lt;i64, DefaultState&lt;FnvHasher&gt;&gt; = HashSet::with_hash_state(DefaultState::&lt;FnvHasher&gt;);
                                                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~
  error: aborting due to previous error
  </code></pre>
  
  <p>How can I get the above example to compile or use a custom hash function in a HashSet/HashMap?</p>