title: What is a clean way to convert a Result into an Option?
body: <p>Before updating to a more recent Rust version the following used to work:</p>
  
  <pre><code>fn example(val: &amp;[&amp;str]) {
      let parsed_value: Vec&lt;usize&gt; = val
          .iter()
          .filter_map(|e| e.parse::&lt;usize&gt;())
          .collect();
  }
  </code></pre>
  
  <p>However, now the parse method returns a <code>Result</code> type instead of an <code>Option</code> and I get the error:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0308]: mismatched types
   --&gt; src/lib.rs:4:25
    |
  4 |         .filter_map(|e| e.parse::&lt;usize&gt;())
    |                         ^^^^^^^^^^^^^^^^^^ expected enum `std::option::Option`, found enum `std::result::Result`
    |
    = note: expected type `std::option::Option&lt;_&gt;`
               found type `std::result::Result&lt;usize, std::num::ParseIntError&gt;`
  </code></pre>
  
  <p>I could create an <code>Option</code> through a conditional, but is there a better / cleaner way?</p>