title: Take slice of certain length known at compile time
body: <p>In this code:</p>
  
  <pre><code>fn unpack_u32(data: &amp;[u8]) -&gt; u32 {
      assert_eq!(data.len(), 4);
      let res = data[0] as u32 |
      (data[1] as u32) &lt;&lt; 8 |
      (data[2] as u32) &lt;&lt; 16 |
          (data[3] as u32) &lt;&lt; 24;
      res
  }
  
  fn main() {
      let v = vec![0_u8, 1_u8, 2_u8, 3_u8, 4_u8, 5_u8, 6_u8, 7_u8, 8_u8];
      println!("res: {:X}", unpack_u32(&amp;v[1..5]));    
  }
  </code></pre>
  
  <p>the function <code>unpack_u32</code> accepts only slices of length 4. Is there any way to replace the runtime check <code>assert_eq</code> with a compile time check?</p>