title: How do I filter out an iterator's values where calling a function returns a Result::Err?
body: <p>How would you iterate through a list and filter out all values where the response <code>Result</code> is not <code>Ok</code>?  I want to do something like <code>filter_map</code>, but it is saying I need to return an <code>Option</code>.</p>
  
  <pre><code>use std::result::Result;
  
  fn match_value(vals: i32) -&gt; Result&lt;i32, i32&gt; {
      match vals {
          2 =&gt; Ok(1),
          _ =&gt; Err(0),
      }
  }
  
  fn main() {
      let values = vec![1, 2, 3, 2];
      let matching = values
          .iter()
          .map(|name| match_value(*name))
          .filter(|x| x.is_ok())
          .collect::&lt;Vec&lt;_&gt;&gt;();
      println!("{:?}", matching);
  }
  </code></pre>