Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUST

rust filtering a vector example

let numbers: Vec<i32> = vec![
  1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
];

let even_numbers = numbers
  .into_iter()
  .filter(|n| n % 2 == 0)
  .collect::<Vec<_>>();

println!("{:?}", even_numbers);
 
PREVIOUS NEXT
Tagged: #rust #filtering #vector
ADD COMMENT
Topic
Name
8+7 =