title: String concatenation in rust
body: <p>I am trying to get a &amp;str and &amp;str to concatenate in a for loop withe intention of using the new combined string after a number of parts have been added to it. A general layout of the for loop can be seen below but I am having a lot of trouble combining strings due to numerous errors.</p>
  <pre><code>for line in reader.lines() {
      let split_line = line.unwrap().split(&quot;,&quot;);
      let mut edited_line = &quot;&quot;;
  
      for word in split_line {
          if !word.contains(&quot;substring&quot;) {
              let test_string = [edited_line, word].join(&quot;,&quot;);
              edited_line = &amp;test_string;
          }
      }
      let _ = writeln!(outfile, &quot;{}&quot;, edited_line).expect(&quot;Unable to write to file&quot;); 
  }
  </code></pre>
  <p>First error:</p>
  <pre><code>error[E0716]: temporary value dropped while borrowed
  </code></pre>
  <p>Comes when running the above.</p>
  <p>Second error:</p>
  <pre><code>error[E0308]: mismatched types expected &amp;str, found struct std::string::String
  </code></pre>
  <p>happens when you remove the &amp; from test_string when it is assigned to edited_line</p>
  <p>Note: <code>format!</code> and <code>concat!</code> macros both also give error 2.<br />
  It seems to be if I get error 2 and convert the <code>std::string:String</code> and convert it to <code>&amp;str</code> I get the error stating the variables don't live long enough.</p>
  <p>How am I supposed to go about building a string of many parts?</p>