nick34992
4/12/2017 - 6:05 PM

Rust: Filter, Collect

Rust: Filter, Collect

fn main() {
  let rng = 0..43;
  let rng_even = rng.filter(|n| is_even(*n)).collect::<Vec<i32>>();
  println!("{:?}", rng_even);
}

fn is_even(n: i32) -> bool {
  n % 2 == 0
}