title: Why does iterating over a HashMap<&str,&str> yield a &&str?
body: <p>I'm iterating over a <code>HashMap</code> and putting the values in it via pattern matching in some local vars.</p>
  
  <p><strong>Delegater</strong></p>
  
  <pre><code>fn lyrics_no_bottles(song_template:&amp;mut String){
      let mut template_partials = HashMap::new();
  
      template_partials.insert("start", "No more bottles");
      template_partials.insert("repeat", "no more bottles");
      template_partials.insert("remaining", "99 bottles");
      template_partials.insert("message", "Go to the store and buy some more");
  
      resolve_template(song_template, template_partials);
  }
  </code></pre>
  
  <p><strong>Called</strong></p>
  
  <pre><code>fn resolve_template(song_template:&amp;mut String, partials: HashMap&lt;&amp;str, &amp;str&gt;){
      let start:&amp;str;
      let repeat:&amp;str;
      let remaining:&amp;str;
      let message:&amp;str;
  
      for key in partials.keys(){
          match key {
              "start" =&gt; start = partials.get(key),
              "repeat" =&gt; repeat = partials.get(key),
              "remaining" =&gt; remaining = partials.get(key),
              "message" =&gt; message = partials.get(key)
          }
      }
  
      *song_template = song_template.replace("%1", start);
      *song_template = song_template.replace("%2", repeat);
      *song_template = song_template.replace("%3", message);
      *song_template = song_template.replace("%4", remaining);
  }
  </code></pre>
  
  <p><strong>Error Output</strong></p>
  
  <pre><code>lib.rs:51:5: 58:6 error: type mismatch resolving `&lt;std::collections::hash::map::Keys&lt;'_, &amp;str, &amp;str&gt; as core::iter::Iterator&gt;::Item == &amp;str`:
   expected &amp;-ptr,
      found str [E0271]
  lib.rs:51     for key in partials.keys(){
  lib.rs:52         match key {
  lib.rs:53             "start" =&gt; start = partials.get(key),
  lib.rs:54             "repeat" =&gt; repeat = partials.get(key),
  lib.rs:55             "remaining" =&gt; remaining = partials.get(key),
  lib.rs:56             "message" =&gt; message = partials.get(key)
            ...
  lib.rs:51:5: 58:6 help: run `rustc --explain E0271` to see a detailed explanation
  lib.rs:53:32: 53:49 error: mismatched types:
   expected `&amp;str`,
      found `core::option::Option&lt;&amp;&amp;str&gt;`
  (expected &amp;-ptr,
      found enum `core::option::Option`) [E0308]
  lib.rs:53             "start" =&gt; start = partials.get(key),
  </code></pre>
  
  <p>I don't understand why the compiler thinks there is a <code>&amp;&amp;str</code> when I declared the parameter as <code>HashMap&lt;&amp;str,&amp;str&gt;</code>.</p>