Skip to content

Instantly share code, notes, and snippets.

@mystal
Created December 22, 2021 18:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mystal/79d6d74f508e9a0ab875a46c7a50c972 to your computer and use it in GitHub Desktop.
Save mystal/79d6d74f508e9a0ab875a46c7a50c972 to your computer and use it in GitHub Desktop.
Print odd number arguments
use std::env;
fn main() {
let odds: Vec<_> = env::args()
.skip(1)
.map(|s| s.parse::<i32>().unwrap())
.filter(|&n| n % 2 != 0)
.collect();
println!("odd numbers: {:?}", odds);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment