title: How do I solve "lifetime of reference outlives lifetime of borrowed content" in the following context?
body: <p>I have the following struct in my lib.rs</p>
  
  <pre><code>pub enum ConfigurationSource {
      StringContent(String),
      FileContent(PathBuf)    
  }
  
  pub struct ConfigurationBuilder&lt;'a&gt; {
      config: Value,
      bundles: HashMap&lt;&amp;'a str, &amp;'a Vec&lt;ConfigurationSource&gt;&gt;    
  }
  
  impl&lt;'a&gt; ConfigurationBuilder&lt;'a&gt;{
      pub fn new(base_source: &amp;ConfigurationSource) -&gt; ConfigurationBuilder{
          let base_config: Value = from_str("{}").unwrap();
  
          let mut config_builder = ConfigurationBuilder{
              config: base_config,
              bundles: HashMap::new()
          };
  
          config_builder.merge_source(&amp;base_source);
  
          return config_builder;
      }
  
      //more code here
  
      pub fn define_bundle(&amp;mut self, bundle_key: &amp;str, sources: &amp;Vec&lt;ConfigurationSource&gt;){
          self.bundles.insert(bundle_key, sources);
      }
  }
  </code></pre>
  
  <p>I do not want the bundles Hashmap in the ConfigurationBuilder instances to own the <code>bundle_key</code>s or <code>source</code>s passed into the <code>define_bundle</code> method.</p>
  
  <p>I get the following two compile errors at build time</p>
  
  <pre><code>error[E0312]: lifetime of reference outlives lifetime of borrowed content...
    --&gt; src\lib.rs:67:41
     |
  67 |         self.bundles.insert(bundle_key, sources);
     |                                         ^^^^^^^
     |
  note: ...the reference is valid for the lifetime 'a as defined on the impl at 27:1...
    --&gt; src\lib.rs:27:1
     |
  27 | / impl&lt;'a&gt; ConfigurationBuilder&lt;'a&gt;{
  28 | |
  29 | |     pub fn new(base_source: &amp;ConfigurationSource) -&gt; ConfigurationBuilder{
  30 | |         let base_config: Value = from_str("{}").unwrap();
  ...  |
  89 | |     }
  90 | | }
     | |_^
  note: ...but the borrowed content is only valid for the anonymous lifetime #3 defined on the method
   body at 66:5
    --&gt; src\lib.rs:66:5
     |
  66 | /     pub fn define_bundle(&amp;mut self, bundle_key: &amp;str, sources: &amp;Vec&lt;ConfigurationSource&gt;){
  67 | |         self.bundles.insert(bundle_key, sources);
  68 | |     }
     | |_____^
  
  error[E0312]: lifetime of reference outlives lifetime of borrowed content...
    --&gt; src\lib.rs:67:29
     |
  67 |         self.bundles.insert(bundle_key, sources);
     |                             ^^^^^^^^^^
     |
  note: ...the reference is valid for the lifetime 'a as defined on the impl at 27:1...
    --&gt; src\lib.rs:27:1
     |
  27 | / impl&lt;'a&gt; ConfigurationBuilder&lt;'a&gt;{
  28 | |
  29 | |     pub fn new(base_source: &amp;ConfigurationSource) -&gt; ConfigurationBuilder{
  30 | |         let base_config: Value = from_str("{}").unwrap();
  ...  |
  89 | |     }
  90 | | }
     | |_^
  note: ...but the borrowed content is only valid for the anonymous lifetime #2 defined on the method
   body at 66:5
    --&gt; src\lib.rs:66:5
     |
  66 | /     pub fn define_bundle(&amp;mut self, bundle_key: &amp;str, sources: &amp;Vec&lt;ConfigurationSource&gt;){
  67 | |         self.bundles.insert(bundle_key, sources);
  68 | |     }
     | |_____^
  </code></pre>
  
  <p>What am I doing wrong?</p>