diff options
author | HampusM <hampus@hampusmat.com> | 2022-08-22 19:13:19 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-08-22 19:13:19 +0200 |
commit | 8e862c7998d0b59c71d20cbcbbc57031f734b6fa (patch) | |
tree | fbcddcfa697d0b67c9d20022004aa2ae16c5a339 /src/di_container_binding_map.rs | |
parent | da3f56d48f9c349b29e1d462b2a535b1a89c5e45 (diff) |
refactor!: move specifying binding scope to a binding scope configurator
BREAKING CHANGE: Specifying the scope of a DI container binding is now done with a binding scope configurator
Diffstat (limited to 'src/di_container_binding_map.rs')
-rw-r--r-- | src/di_container_binding_map.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/di_container_binding_map.rs b/src/di_container_binding_map.rs index e64ff17..20d040f 100644 --- a/src/di_container_binding_map.rs +++ b/src/di_container_binding_map.rs @@ -31,19 +31,22 @@ impl DIContainerBindingMap .as_ref()) } - pub fn set<Interface>(&mut self, provider: Box<dyn IProvider>) -> Option<()> + pub fn set<Interface>(&mut self, provider: Box<dyn IProvider>) where Interface: 'static + ?Sized, { let interface_typeid = TypeId::of::<Interface>(); - if self.bindings.contains_key(&interface_typeid) { - return None; - } - self.bindings.insert(interface_typeid, provider); + } + + pub fn has<Interface>(&self) -> bool + where + Interface: 'static + ?Sized, + { + let interface_typeid = TypeId::of::<Interface>(); - Some(()) + self.bindings.contains_key(&interface_typeid) } /// Only used by tests in the `di_container` module. |