Skip to content

Instantly share code, notes, and snippets.

Created February 14, 2017 04:09
Show Gist options
  • Save anonymous/9294daebb548dd14e055597b00f46703 to your computer and use it in GitHub Desktop.
Save anonymous/9294daebb548dd14e055597b00f46703 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
fn main() {
let a = ["1", "2", "lol"];
let mut iter = a.iter().filter_map(|s| s.parse().ok());
assert_eq!(iter.next(), Some(1));
assert_eq!(iter.next(), Some(2));
assert_eq!(iter.next(), None);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment