dirk_framework 0.1.1

Dependency Injection for Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//! An example of injecting generic types

use dirk_framework::component;
use dirk_framework::component::{builder::Builder, Component};

#[component(answer: cloned_instance_bind(T))]
trait GenericComponent<T: Clone + 'static> {
    fn answer(&self) -> T;
}

fn main() {
    let component = DirkGenericComponent::builder().answer(42).build();
    assert_eq!(component.answer(), 42);
}