From 607d8d50b76665b67ca6f3124aa81773bec110b7 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 25 Dec 2023 22:53:13 +0100 Subject: WIP Linkme dependency removal --- src/di_container/blocking/mod.rs | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'src/di_container/blocking/mod.rs') diff --git a/src/di_container/blocking/mod.rs b/src/di_container/blocking/mod.rs index d9efe94..7286f48 100644 --- a/src/di_container/blocking/mod.rs +++ b/src/di_container/blocking/mod.rs @@ -55,8 +55,6 @@ use crate::di_container::binding_storage::DIContainerBindingStorage; use crate::di_container::blocking::binding::builder::BindingBuilder; use crate::di_container::BindingOptions; use crate::errors::di_container::DIContainerError; -use crate::private::cast::boxed::CastBox; -use crate::private::cast::rc::CastRc; use crate::provider::blocking::{IProvider, Providable}; use crate::ptr::SomePtr; use crate::util::use_double; @@ -267,22 +265,28 @@ impl DIContainer .get_binding_providable::(binding_options, dependency_history)?; match binding_providable { - Providable::Transient(transient_binding) => Ok(SomePtr::Transient( - transient_binding.cast::().map_err(|_| { - DIContainerError::CastFailed { + Providable::Transient(transient_binding) => { + let ptr_buf = transient_binding.into_ptr_buffer_box(); + + ptr_buf + .cast_into_boxed::() + .ok_or_else(|| DIContainerError::CastFailed { interface: type_name::(), binding_kind: "transient", - } - })?, - )), - Providable::Singleton(singleton_binding) => Ok(SomePtr::Singleton( - singleton_binding.cast::().map_err(|_| { - DIContainerError::CastFailed { + }) + .map(SomePtr::Transient) + } + Providable::Singleton(singleton_binding) => { + let ptr_buf = singleton_binding.into_ptr_buffer_rc(); + + ptr_buf + .cast_into_rc::() + .ok_or_else(|| DIContainerError::CastFailed { interface: type_name::(), binding_kind: "singleton", - } - })?, - )), + }) + .map(SomePtr::Singleton) + } #[cfg(feature = "factory")] Providable::Factory(factory_binding) => { use crate::castable_factory::CastableFactory; -- cgit v1.2.3-18-g5258