Add contains method for checking if a type is already in the map.

This commit is contained in:
Jonathan Reem 2014-08-13 21:01:19 -07:00
parent 6daea53385
commit 2e37f0d1ae

View file

@ -141,6 +141,11 @@ impl AnyMap {
pub fn remove<T: 'static>(&mut self) { pub fn remove<T: 'static>(&mut self) {
self.data.remove(&TypeId::of::<T>()); self.data.remove(&TypeId::of::<T>());
} }
/// Does a value of type `T` exist?
pub fn contains<T: 'static>(&self) -> bool {
self.data.contains_key(&TypeId::of::<T>())
}
} }
impl Collection for AnyMap { impl Collection for AnyMap {