From cab26b170945d9d6c885112c2f83089dd0fad914 Mon Sep 17 00:00:00 2001 From: Oscar Beaumont Date: Sun, 24 Dec 2023 13:58:12 +0800 Subject: [PATCH] fixes #198 - allow removing items from `TypeMap` --- src/type/map.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/type/map.rs b/src/type/map.rs index 0e593fb4..3eb021d3 100644 --- a/src/type/map.rs +++ b/src/type/map.rs @@ -46,6 +46,14 @@ impl TypeMap { self.map.len() } + pub fn contains_key(&self, sid: SpectaID) -> bool { + self.map.contains_key(&sid) + } + + pub fn remove(&mut self, sid: SpectaID) -> Option { + self.map.remove(&sid).flatten() + } + // TODO: It would be nice if this would a proper `Iterator` or `IntoIterator` implementation! pub fn iter(&self) -> impl Iterator { #[allow(clippy::unnecessary_filter_map)]