From 8e862c7998d0b59c71d20cbcbbc57031f734b6fa Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 22 Aug 2022 19:13:19 +0200 Subject: 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 --- src/di_container_binding_map.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/di_container_binding_map.rs') 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(&mut self, provider: Box) -> Option<()> + pub fn set(&mut self, provider: Box) where Interface: 'static + ?Sized, { let interface_typeid = TypeId::of::(); - if self.bindings.contains_key(&interface_typeid) { - return None; - } - self.bindings.insert(interface_typeid, provider); + } + + pub fn has(&self) -> bool + where + Interface: 'static + ?Sized, + { + let interface_typeid = TypeId::of::(); - Some(()) + self.bindings.contains_key(&interface_typeid) } /// Only used by tests in the `di_container` module. -- cgit v1.2.3-18-g5258