Created
February 14, 2017 04:09
-
-
Save anonymous/9294daebb548dd14e055597b00f46703 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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