How to retain elements in Vec

Use the `retain` method with a closure to keep specific elements in a `Vec` and remove the rest in place.

To retain elements in a Vec, use the retain method, which keeps only the elements that satisfy a given closure condition. This method modifies the vector in place, removing any elements for which the closure returns false.

let mut v = vec![1, 2, 3, 4, 5];
v.retain(|&x| x % 2 == 0);
// v is now [2, 4]