From a66d8589c2fd0048680d68945a47ab20fd3f3938 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sat, 9 Feb 2019 10:45:35 -0800 Subject: [PATCH] add Extensions::contains method --- src/extensions.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/extensions.rs b/src/extensions.rs index f7805641b..148e4c18e 100644 --- a/src/extensions.rs +++ b/src/extensions.rs @@ -26,6 +26,11 @@ impl Extensions { self.map.insert(TypeId::of::(), Box::new(val)); } + /// Check if container contains entry + pub fn contains(&self) -> bool { + self.map.get(&TypeId::of::()).is_some() + } + /// Get a reference to a type previously inserted on this `Extensions`. pub fn get(&self) -> Option<&T> { self.map