title: Is there a method like JavaScript's substr in Rust?
body: <p>I looked at the Rust <a href="http://doc.rust-lang.org/std/string/struct.String.html" rel="noreferrer">docs for <code>String</code></a> but I can't find a way to extract a substring.</p>
  
  <p>Is there a method like JavaScript's <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr" rel="noreferrer"><code>substr</code></a> in Rust? If not, how would you implement it?</p>
  
  <pre><code>str.substr(start[, length])
  </code></pre>
  
  <p>The closest is probably <code>slice_unchecked</code> but it uses byte offsets instead of character indexes and is marked <code>unsafe</code>.</p>