title: Why can't I cast a `u32` to `char`?
body: <p>I'm trying to learn Rust and I got caught up thinking about how <code>char</code>s are 4 bytes wide. I can cast a <code>char</code> to a <code>u32</code> and it works out (they are both 4 bytes wide), however, when I cast from a <code>u32</code> to a <code>char</code>, Rust complains:</p>
  
  <pre><code>fn main() {
      let pizza_hex: u32 = 0x1f355;
      let pizza: char = ''; // (pizza char: http://www.fileformat.info/info/unicode/char/1f355/index.htm)
  
      // pizza as hex = 1f355
      println!("pizza as hex = {:x}", pizza as u32);
  
      // size of pizza = 4
      println!("size of pizza = {}", std::mem::size_of_val(&amp;pizza));
  
      // This doesn't work super well
      println!("{} == {}", pizza_hex as char, pizza);
  }
  </code></pre>
  
  <pre class="lang-none prettyprint-override"><code>error[E0604]: only `u8` can be cast as `char`, not `u32`
    --&gt; src/main.rs:12:26
     |
  12 |     println!("{} == {}", pizza_hex as char, pizza);
     |                          ^^^^^^^^^^^^^^^^^
  </code></pre>
  
  <p>Any ideas why?</p>