title: Reverse order of a reference to immutable array slice
body: <p>I would like to reverse the order of a slice:</p>
  
  <pre><code>&amp;[1, 2, 3] -&gt; &amp;[3, 2, 1]
  </code></pre>
  
  <p>This is my code:</p>
  
  <pre><code>fn iterate_over_file(data: &amp;[u8], ...) -&gt; ... {
      ...
      for cur_data in data.chunks(chunk_size) {
           let reversed_cur_data = cur_data.reverse() // this returns ()
           ...
      ...
   }
  </code></pre>
  
  <p>This <code>data</code> parameter comes from a file I read in using <a href="https://docs.rs/filebuffer/0.1.1/filebuffer/struct.FileBuffer.html" rel="noreferrer"><code>FileBuffer</code></a>, and I'd like to keep it as a referenced slice (and not turn it into an owned <code>Vec</code>, since it's a heavy computation to make).</p>
  
  <p>How could I reverse the order of <code>cur_data</code> with the minimal amount of operations and memory allocation? Its length is known for a specific runtime of my program (called here <code>chunk_size</code>), but it changes between different runs. <code>reversed()</code> seems to return <code>()</code>, which makes sense as it's done in-place, and I only have a referenced slice. <code>.iter().rev()</code> creates an iterator, but then I'd have to call <code>.next()</code> on it several times to get the slice back, which is both not elegant and not effective, as I have at least tens of millions of <code>cur_data</code> lines per file.</p>