From: Jonathan Reem Date: Thu, 14 Aug 2014 04:01:19 +0000 (-0700) Subject: Add contains method for checking if a type is already in the map. X-Git-Tag: 0.9.1~16^2 X-Git-Url: https://git.chrismorgan.info/anymap/commitdiff_plain/2e37f0d1aebbd0c56acd0de7b46d14cd71d3e134?hp=6daea5338511debd17890e14082d6b8a4c00a368 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 {