From a362f51523eaa6ab1c58636f87fd040a6c10d655 Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Wed, 11 Sep 2024 22:57:58 +0000 Subject: [PATCH] feat(index): add `IndexVec::shrink_to` (#5713) Add `IndexVec::shrink_to` to match `std::vec::Vec::shrink_to`. --- crates/oxc_index/src/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/oxc_index/src/lib.rs b/crates/oxc_index/src/lib.rs index 1b2892b4a..36025b919 100644 --- a/crates/oxc_index/src/lib.rs +++ b/crates/oxc_index/src/lib.rs @@ -371,6 +371,12 @@ impl IndexVec { self.raw.shrink_to_fit(); } + /// Shrinks the capacity of the vector with a lower bound. + #[inline] + pub fn shrink_to(&mut self, min_capacity: usize) { + self.raw.shrink_to(min_capacity); + } + /// Shortens the vector, keeping the first `len` elements and dropping /// the rest. See [`Vec::truncate`] #[inline]