title: Cannot return a vector slice - ops::Range<i32> is not implemented
body: <p>Why does the following Rust code give an error?</p>
  
  <pre><code>fn getVecSlice(vec: &amp;Vec&lt;f64&gt;, start: i32, len: i32) -&gt; &amp;[f64] {
      vec[start..start + len]
  }
  </code></pre>
  
  <p>The error message I get is</p>
  
  <pre class="lang-none prettyprint-override"><code>the trait `core::ops::Index&lt;core::ops::Range&lt;i32&gt;&gt;` is not implemented for the type `collections::vec::Vec&lt;f64&gt;` [E0277]
  </code></pre>
  
  <p>In later versions of Rust, I get</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0277]: the trait bound `std::ops::Range&lt;i32&gt;: std::slice::SliceIndex&lt;[f64]&gt;` is not satisfied
   --&gt; src/main.rs:2:9
    |
  2 |         vec[start..start + len]
    |         ^^^^^^^^^^^^^^^^^^^^^^^ slice indices are of type `usize` or ranges of `usize`
    |
    = help: the trait `std::slice::SliceIndex&lt;[f64]&gt;` is not implemented for `std::ops::Range&lt;i32&gt;`
    = note: required because of the requirements on the impl of `std::ops::Index&lt;std::ops::Range&lt;i32&gt;&gt;` for `std::vec::Vec&lt;f64&gt;`
  </code></pre>
  
  <p>I'm trying to simulate a 2 dimensional matrix using the <code>Vec</code> type and return references to the different rows of the matrix.What is the best way to achieve this?</p>