title: How to replace a part of Vec with a slice?
body: <p>I have a <code>Vec&lt;f32&gt;</code> like this:</p>
  
  <pre><code>let mut v: Vec&lt;f32&gt; = Vec::new();
  v.push(1.0);
  v.push(2.0);
  v.push(3.0);
  </code></pre>
  
  <p>Is there an idiomatic way to replace a portion of the contents with a slice? I have a function like this:</p>
  
  <pre><code>fn replace(&amp;mut v: Vec&lt;f32&gt;, start: usize, vals: &amp;[f32]) {
      // ...
  }
  </code></pre>
  
  <p>In this case, I'd like to replace the values in <code>v</code> with values from <code>vals</code>, starting from the index <code>start</code> of <code>v</code>. If I have the aforementioned <code>Vec</code>, I'd like to do this:</p>
  
  <pre><code>// Before v contains (1.0, 2.0, 3.0)
  replace(&amp;v, 0, &amp;[4.0, 5.0]);
  // Now v would contain (4.0, 5.0, 3.0)
  </code></pre>
  
  <p>I guess this could be done by iterating starting from the <code>start</code> index, but is there a more idiomatic Rust way of doing this?</p>