AzureMarker / shaku

Compile Time Dependency lnjection Library for Rust
https://docs.rs/shaku
Apache License 2.0
429 stars 22 forks source link

Suggestion: provide an advanced sample project #9

Open leinardi opened 3 years ago

leinardi commented 3 years ago

I am new to Rust and I would have found very useful an advanced sample project showcasing every possible feature of shaku.

What I would like to have in this example is simultaneous use of Components and Providers, custom Components that create new instances using a static ::new() constructor and have dependencies on other Components and Providers. Something like:

impl<M: Module + HasComponent<dyn Logger>> Component<M> for DateLoggerImpl {
    type Interface = dyn DateLogger;
    type Parameters = ();

    fn build(context: &mut ModuleBuildContext<M>, parameters: ()) -> Box<dyn DateLogger> {
        Box::new(Self::new(context.build_component()))
    }
}