| Crates.io | vec_remove_if |
| lib.rs | vec_remove_if |
| version | 1.0.0 |
| created_at | 2022-07-23 19:10:44.746057+00 |
| updated_at | 2022-07-23 19:10:44.746057+00 |
| description | Extract elements from a vector based on supplied criteria |
| homepage | |
| repository | https://gitlab.com/SnSDev/vec_remove_if |
| max_upload_size | |
| id | 631683 |
| size | 6,410 |
Extract elements from a vector based on supplied criteria
Project by SnS Development
Need to filter some elements out of an existing Vector through a mutable borrow
A trait implemented on Vec<T> with 2 functions remove_if and
swap_remove_if that iterate over elements, runs a supplied closure,
and removes elements where the closure returns [true].
use vec_remove_if::VecRemoveIf;
let mut v = vec![1, 12, 3, 14, 5, 16, 7, 18];
assert_eq!(
vec![12, 14, 16, 18],
v.remove_if(|e| e > &10)
);
assert_eq!(
vec![1, 3, 5, 7],
v
);
License: MIT