How to filter a vector in Rust?In Rust you can filter vectors by
.into_iter().filter()and then collect it into another vector using
Example of filtering vec in RustIn below example we will be filtering numbers in vec which can be divided by 2.
[2, 4, 6, 8, 10]
Another example of filtering vec in RustIn below example we will be filtering names in vec which contains letter a.
["William", "Jason", "Anna", "Sabrina", "Micheal"]