title: How do I write a u32 in a &[u8]?
body: <p>I'm trying to render an image. I wrote a <code>put_pixel</code> function to write a RGBA pixel into an array that represents the image. </p>
  
  <p>The image is one dimensional array that holds <code>i8</code> values(every byte is a component of the color). I'd like to write the color in a single step.</p>
  
  <pre><code>fn put_pixel(x: u16, y: u16, color: u32, width: u16, height: u16, buffer: &amp;[u8]) {
      let index = 0; // I'll calculate the right index later.
      buffer[index] as u32 = color; // I want to write the color here.
  }
  </code></pre>
  
  <p>So, this gave me an error saying that</p>
  
  <pre class="lang-none prettyprint-override"><code>45 |     buffer[index] = color;
     |                     ^^^^^ expected u8, found u32
  </code></pre>
  
  <p>Sounds logical, but I don't know how to "cast" the pixel into the array.</p>