title: How to mutate iterator elements in Rust to reverse substrings
body: <p>I am trying to make a function that will do the following:<br>
  <strong>input:</strong> a <code>String</code> of arbitrary length of the form "abc/def/ghi"<br>
  <strong>output:</strong> a <code>String</code> where all the substrings separated by "/" are reversed; in this example, the output would be "cba/fed/ihg".</p>
  
  <p>More than the function itself, I care about the general principle behind mutating an iterator generated by the <code>split()</code> function.</p>
  
  <p>Below is my best effort:</p>
  
  <pre><code>fn reverse_string(input: &amp;mut str) -&gt; String {
      input
          .to_string()
          .split('/')
          .map(move |x| x.to_string().rev())
          .collect::&lt;String&gt;()
  }
  </code></pre>
  
  <p>The compiler complains that</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0599]: no method named `rev` found for type `std::string::String` in the current scope
   --&gt; src/main.rs:5:37
    |
  5 |         .map(move |x| x.to_string().rev())
    |                                     ^^^
    |
    = note: the method `rev` exists but the following trait bounds were not satisfied:
            `&amp;mut std::string::String : std::iter::Iterator`
            `&amp;mut str : std::iter::Iterator`
  </code></pre>
  
  <p>What does that mean and how can I resolve this problem?</p>