title: How to create a lazy_static HashMap with function references as value?
body: <p>I tried to create a <code>HashMap</code> with functions as the values:</p>
  
  <pre><code>#[macro_use]
  extern crate lazy_static;
  
  use std::collections::HashMap;
  
  lazy_static! {
      static ref HASHES: HashMap&lt;&amp;'static str, &amp;'static Fn([u8])&gt; = {
          let mut m = HashMap::new();
          m.insert("md5", &amp;md5);
          m
      };
  }
  
  fn md5(bytes: &amp;[u8]) -&gt; String {
      String::default()
  }
  </code></pre>
  
  <p>The compiler gives me an error:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0277]: the trait bound `std::ops::Fn([u8]) + 'static: std::marker::Sync` is not satisfied in `&amp;'static std::ops::Fn([u8]) + 'static`
    --&gt; src/main.rs:6:1
     |
  6  |   lazy_static! {
     |  _^ starting here...
  7  | |     static ref HASHES: HashMap&lt;&amp;'static str, &amp;'static Fn([u8])&gt; = {
  8  | |         let mut m = HashMap::new();
  9  | |         m.insert("md5", &amp;md5);
  10 | |         m
  11 | |     };
  12 | | }
     | |_^ ...ending here: within `&amp;'static std::ops::Fn([u8]) + 'static`, the trait `std::marker::Sync` is not implemented for `std::ops::Fn([u8]) + 'static`
     |
     = note: `std::ops::Fn([u8]) + 'static` cannot be shared between threads safely
     = note: required because it appears within the type `&amp;'static std::ops::Fn([u8]) + 'static`
     = note: required because of the requirements on the impl of `std::marker::Sync` for `std::collections::hash::table::RawTable&lt;&amp;'static str, &amp;'static std::ops::Fn([u8]) + 'static&gt;`
     = note: required because it appears within the type `std::collections::HashMap&lt;&amp;'static str, &amp;'static std::ops::Fn([u8]) + 'static&gt;`
     = note: required by `lazy_static::lazy::Lazy`
     = note: this error originates in a macro outside of the current crate
  </code></pre>
  
  <p>I don't understand what should I do to fix this error and I don't know any other way of creating such a <code>HashMap</code>.</p>