From 2e37f0d1aebbd0c56acd0de7b46d14cd71d3e134 Mon Sep 17 00:00:00 2001 From: Jonathan Reem Date: Wed, 13 Aug 2014 21:01:19 -0700 Subject: [PATCH] Add contains method for checking if a type is already in the map. --- src/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 1fae987..0c71e36 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -141,6 +141,11 @@ impl AnyMap { pub fn remove(&mut self) { self.data.remove(&TypeId::of::()); } + + /// Does a value of type `T` exist? + pub fn contains(&self) -> bool { + self.data.contains_key(&TypeId::of::()) + } } impl Collection for AnyMap {