title: Performance penalty of using clone_from_slice() instead of copy_from_slice()?
body: <p>In Rust, there are two methods to update the content of a slice from another slice: <a href="https://doc.rust-lang.org/std/primitive.slice.html#method.clone_from_slice" rel="nofollow noreferrer"><code>clone_from_slice()</code></a> and <a href="https://doc.rust-lang.org/std/primitive.slice.html#method.copy_from_slice" rel="nofollow noreferrer"><code>copy_from_slice()</code></a>.  The behavior of these two functions are unsurprising - the first does a clone and expects the type to implement <code>Clone</code>, while the second does a copy and expects the type to implement <code>Copy</code>.</p>
  <p>However, it surprises me that the documentation for <code>clone_from_slice</code> says this: &quot;If <code>T</code> implements <code>Copy</code>, it can be more performant to use <code>copy_from_slice</code>.&quot;  It is surprising that there should be a performance difference here.  If <code>T</code> implements <code>Copy</code>, then <code>.clone()</code> is required to be equivalent to copying bits; however since the compiler knows what type <code>T</code> is, it should be able to figure out if it can do a bitwise copy even if I use <code>clone_from_slice</code>.</p>
  <p>So where does the performance inefficiency arise from?</p>