Answers for "how to remove from vec rust"

C
1

remove on condtion in vec rust

let mut vec = vec![1, 2, 3, 4];
vec.retain(|&x| x % 2 == 0);
assert_eq!(vec, [2, 4]);
Posted by: Guest on October-09-2021

Code answers related to "C"

Browse Popular Code Answers by Language