From d01cbf9b5ac6547c6d7c457cd220bc85f2b16e7a Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Tue, 26 May 2020 12:47:48 -0400 Subject: [PATCH] Use ProviderFn in simple_no_macros example --- shaku/examples/simple_no_macros.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/shaku/examples/simple_no_macros.rs b/shaku/examples/simple_no_macros.rs index 9a866d2..46d170e 100644 --- a/shaku/examples/simple_no_macros.rs +++ b/shaku/examples/simple_no_macros.rs @@ -4,7 +4,7 @@ use shaku::{ Component, HasComponent, HasProvider, Interface, Module, ModuleBuildContext, ModuleBuilder, - Provider, + Provider, ProviderFn, }; use std::error::Error; use std::fmt::Debug; @@ -56,6 +56,7 @@ impl> Provider for SampleServi struct SampleModule { sample_dependency: Arc, + sample_service: Arc>, } impl Module for SampleModule { type Submodules = (); @@ -63,6 +64,7 @@ impl Module for SampleModule { fn build(context: &mut ModuleBuildContext) -> Self { Self { sample_dependency: Self::build_component(context), + sample_service: context.provider_fn::(), } } } @@ -85,7 +87,7 @@ impl HasComponent for SampleModule { } impl HasProvider for SampleModule { fn provide(&self) -> Result, Box> { - SampleServiceImpl::provide(self) + (self.sample_service)(self) } }