title: How to cast an [u8] array larger than 8 bytes to an integer?
body: <p>Because of the length of the array, I can't use <a href="https://doc.rust-lang.org/std/primitive.i32.html#method.from_ne_bytes" rel="nofollow noreferrer"><code>i32::from_ne_bytes()</code></a>, but of course, the following works especially since the code will run only on a cpu architecture supporting unaligned access (or that because of the small length, the whole array might get stored accross several cpu registers).</p>
  <pre><code>fn main() {
      let buf: [u8; 10] = [0, 0, 0, 1, 0x12, 14, 50, 120, 250, 6];
      println!(&quot;1 == {}&quot;, unsafe{std::ptr::read(&amp;buf[1])} as i32);
  }
  </code></pre>
  <p>But is there a cleaner way to do it while still not copying the array?</p>