title: Return a Formatted String in Rust
body: <p>I'd like to create a function that takes an <code>x</code> and <code>y</code> coordinate values and returns a string of the format <code>(x,y)</code>:</p>
  <pre class="lang-rust prettyprint-override"><code>pub struct Coord {
      x: i32,
      y: i32,
  }
  
  fn main() {
      let my_coord = Coord {
          x: 10,
          y: 12
      };
  
      let my_string = coords(my_coord.x, my_coord.y);
  
      fn coords(x: i32, y: i32) -&gt; &amp;str{
          let l = vec![&quot;(&quot;, x.to_string(), &quot;,&quot;, y.to_string(), &quot;)&quot;];
          let j = l.join(&quot;&quot;);
          println!(&quot;{}&quot;, j);
          return &amp;j
      }
  }
  </code></pre>
  <p>This gives me the error:</p>
  <pre class="lang-none prettyprint-override"><code>   |
  14 |     fn coords(x: i32, y: i32) -&gt; &amp;str {
     |                                  ^ expected named lifetime parameter
     |
     = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments
  help: consider using the `'static` lifetime
     |
  </code></pre>
  <p>Adding the <code>'static</code> lifetime seems to cause a host of other problems with this function? How can I fix this?</p>