Chris Morgan
›
Git
›
anymap
› blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
commit
grep
author
committer
pickaxe
?
search:
re
Add contains method for checking if a type is already in the map.
[anymap]
/
src
/
lib.rs
diff --git
a/src/lib.rs
b/src/lib.rs
index 1fae987a0931e41530dd3de0829607ced2c54416..0c71e367ab39814bb219a547cce50ef7bdc46a9e 100644
(file)
--- a/
src/lib.rs
+++ b/
src/lib.rs
@@
-141,6
+141,11
@@
impl AnyMap {
pub fn remove<T: 'static>(&mut self) {
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 {