mirror of
https://github.com/actix/actix-web.git
synced 2025-05-15 04:08:56 +00:00
add Extensions::contains method
This commit is contained in:
parent
6a343fae06
commit
a66d8589c2
1 changed files with 5 additions and 0 deletions
|
@ -26,6 +26,11 @@ impl Extensions {
|
|||
self.map.insert(TypeId::of::<T>(), Box::new(val));
|
||||
}
|
||||
|
||||
/// Check if container contains entry
|
||||
pub fn contains<T: 'static>(&self) -> bool {
|
||||
self.map.get(&TypeId::of::<T>()).is_some()
|
||||
}
|
||||
|
||||
/// Get a reference to a type previously inserted on this `Extensions`.
|
||||
pub fn get<T: 'static>(&self) -> Option<&T> {
|
||||
self.map
|
||||
|
|
Loading…
Reference in a new issue