Erase all elements in a vector with Rust
We should have or make a vector. Now, we want to leave the vector empty. Let's see how to do this with a single line solution.
// Create a vector
let vector = vec![0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 8.0, 9.0];
// Delete every single element
vector.retain(|_element| false);
Done!
support
Did you find this post useful?
Remember that this website doesn’t make use of any trackers or analytics or adv so it doesn’t earn from your visits (moreover, it has a minimal environmental impact).
If you like this blog, refill my caffeine supplies by
share