From 4e2440daec173e3fd6d24f8f5d14150a9e8e19cf Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Mon, 25 Nov 2019 14:46:16 -0800 Subject: [PATCH] Add a 'clear' method to map. --- lib/runtime-core/src/structures/map.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/runtime-core/src/structures/map.rs b/lib/runtime-core/src/structures/map.rs index b3f20b5cb..08773b50a 100644 --- a/lib/runtime-core/src/structures/map.rs +++ b/lib/runtime-core/src/structures/map.rs @@ -37,6 +37,11 @@ where } } + /// Clears the map. Keeps the allocated memory for future use. + pub fn clear(&mut self) { + self.elems.clear(); + } + /// Returns the size of this map. pub fn len(&self) -> usize { self.elems.len()