title: Edit string in place with a function
body: <p>I am trying to edit a string in place by passing it to mutate(), see below. </p>
  
  <p>Simplified example:</p>
  
  <pre><code>fn mutate(string: &amp;mut &amp;str) -&gt; &amp;str {
      string[0] = 'a'; // mutate string
      string
  }
  
  fn do_something(string: &amp;str) {
      println!("{}", string);
  }
  
  fn main() {
      let string = "Hello, world!";
      loop {
          string = mutate(&amp;mut string);
          do_something(string);
      }
  }
  </code></pre>
  
  <p>But I get the following compilation error:</p>
  
  <pre><code>main.rs:1:33: 1:37 error: missing lifetime specifier [E0106]
  main.rs:1 fn mutate(string: &amp;mut &amp;str) -&gt; &amp;str {
                                            ^~~~
  main.rs:1:33: 1:37 help: this function's return type contains a borrowed value, but the signature does not say which one of `string`'s 2 elided lifetimes it is borrowed from
  main.rs:1 fn mutate(string: &amp;mut &amp;str) -&gt; &amp;str {
                                            ^~~~
  </code></pre>
  
  <p>Why do I get this error and how can I achieve what I want?</p>