title: What is an elegant way to deal with remainders when splitting a vector into chunks?
body: <p>I have a buffer of 10 bytes:</p>
  
  <ul>
  <li>header: 3 bytes</li>
  <li>payload: 7 bytes</li>
  </ul>
  
  <p>I have a larger payload (<code>in_data: Vec&lt;u8&gt;</code>) that I need to split into chunks:</p>
  
  <pre><code>let mut buffer = vec![0u8; 10];
  
  for chunk in in_data.chunks(7) {
      buffer[3..].copy_from_slice(chunk);
      // Do something with each packet.. send to device, etc.
  }
  </code></pre>
  
  <p>This is good if all chunks are size 7, but when there is a remainder, <code>copy_from_slice</code> fails because the chunk is smaller than the buffer slice.</p>
  
  <p>I could add ifs, checks, etc. Ideally, I would like to fill any remaining space in the buffer with zeros but this is not critical.</p>
  
  <p>What is an elegant Rust way of dealing with this?</p>