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 --- examples/unbound/bootstrap.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'examples/unbound/bootstrap.rs') diff --git a/examples/unbound/bootstrap.rs b/examples/unbound/bootstrap.rs index dc8468c..f59bc83 100644 --- a/examples/unbound/bootstrap.rs +++ b/examples/unbound/bootstrap.rs @@ -1,3 +1,5 @@ +use std::error::Error; + use syrette::DIContainer; // Concrete implementations @@ -10,21 +12,20 @@ use crate::interfaces::animal_store::IAnimalStore; use crate::interfaces::dog::IDog; use crate::interfaces::human::IHuman; -pub fn bootstrap() -> DIContainer +pub fn bootstrap() -> Result> { let mut di_container: DIContainer = DIContainer::new(); di_container .bind::() - .to_singleton::() - .unwrap(); + .to::()? + .in_singleton_scope()?; - di_container.bind::().to::().unwrap(); + di_container.bind::().to::()?; di_container .bind::() - .to::() - .unwrap(); + .to::()?; - di_container + Ok(di_container) } -- cgit v1.2.3-18-g5258