title: How do you remove a sub-string according to index from a Rust String or &str type?
body: <p>I have an &amp;str type string from which I want to remove a sub-string. I have an algorithm to calculate the start and end positions of the part to be removed. How can I now remove the sub-string?</p>
  <p>To illustrate this clearer, if I were using C++, I would do this:</p>
  <pre><code>#include&lt;iostream&gt;
  #include&lt;string&gt;
  
      int main(){
          std::string foo = &quot;Hello&quot;;
          int start = 2,stop = 4;
          std::cout&lt;&lt;foo;
          foo.erase(start, stop - start);
          std::cout&lt;&lt;std::endl&lt;&lt;foo&lt;&lt;std::endl;
      }
  </code></pre>
  <p>My code in Rust:</p>
  <pre><code>fn main(){
      let mut foo: &amp;str = &quot;hello&quot;;
      let start: i32 = 0;
      let stop: i32 = 4;
      //what goes here?
  }
       
  </code></pre>