From 831d0334710b98abbc10d0c230059f98201d8164 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 2 Jan 2019 12:01:36 -0800 Subject: [PATCH] Add a `shrink_to_fit` function to `PrimaryMap`. --- lib/entity/src/primary.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/entity/src/primary.rs b/lib/entity/src/primary.rs index 7a45fa9582..8f1daed7e3 100644 --- a/lib/entity/src/primary.rs +++ b/lib/entity/src/primary.rs @@ -135,6 +135,11 @@ where self.elems.reserve_exact(additional) } + /// Shrinks the capacity of the `PrimaryMap` as much as possible. + pub fn shrink_to_fit(&mut self) { + self.elems.shrink_to_fit() + } + /// Consumes this `PrimaryMap` and produces a `BoxedSlice`. pub fn into_boxed_slice(self) -> BoxedSlice { unsafe { BoxedSlice::::from_raw(Box::<[V]>::into_raw(self.elems.into_boxed_slice())) }