title: What does “`str` does not have a constant size known at compile-time” mean, and what's the simplest way to fix it?
body: <p>I'm trying to manipulate a string derived from a function parameter and then return the result of that manipulation:</p>
  
  <pre><code>fn main() {
      let a: [u8; 3] = [0, 1, 2]; 
      for i in a.iter() {
          println!("{}", choose("abc", *i));
      }
  }
  
  fn choose(s: &amp;str, pad: u8) -&gt; String {
      let c = match pad {
          0 =&gt; ["000000000000000", s].join("")[s.len()..],
          1 =&gt; [s, "000000000000000"].join("")[..16],
          _ =&gt; ["00", s, "0000000000000"].join("")[..16],
      };
      c.to_string()
  }
  </code></pre>
  
  <p>On building, I get this error:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0277]: the trait bound `str: std::marker::Sized` is not satisfied
   --&gt; src\main.rs:9:9
    |
  9 |     let c = match pad {
    |         ^ `str` does not have a constant size known at compile-time
    |
    = help: the trait `std::marker::Sized` is not implemented for `str`
    = note: all local variables must have a statically known size
  </code></pre>
  
  <p>What's wrong here, and what's the simplest way to fix it?</p>