From: Chris Morgan Date: Thu, 14 Aug 2014 07:41:46 +0000 (+1000) Subject: Merge pull request #9 from reem/contains X-Git-Tag: 0.9.1~16 X-Git-Url: https://git.chrismorgan.info/anymap/commitdiff_plain/c2473c1fceb1878e1db0a9050c2764938872e241?hp=6daea5338511debd17890e14082d6b8a4c00a368 Merge pull request #9 from reem/contains Add contains method for checking if a type is already in the map. --- 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 {