pub trait Provider<T: ?Sized> {
    type Impl;

    // Required methods
    fn get(&mut self) -> Wrc<Self::Impl>;
    fn create(&mut self) -> Self::Impl;

    // Provided methods
    fn get_ref(&mut self) -> &Self::Impl { ... }
    fn create_boxed(&mut self) -> Box<Self::Impl> { ... }
}

Required Associated Types§

Required Methods§

source

fn get(&mut self) -> Wrc<Self::Impl>

source

fn create(&mut self) -> Self::Impl

Provided Methods§

source

fn get_ref(&mut self) -> &Self::Impl

Examples found in repository?
examples/3_inject_options_list.rs (line 98)
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
fn main() {
    let mut container = Container::<profiles::Default>::new();

    let comp = Provider::<Comp>::get_ref(&mut container);
    comp.comp();
    comp.int();
    comp.int2();

    let comp = Provider::<dyn Interface>::get_ref(&mut container);
    comp.int();


    let mut container = Container::<profiles::Dev>::new();
    let comp = Provider::<dyn Interface>::get_ref(&mut container);
    comp.int();

    let comp = Provider::<dyn Interface2>::get_ref(&mut container);
    comp.int2();


    println!("Using profile: {}", APP_PROFILE.as_str());
    let comp = inject!(Comp: profiles::Default, profiles::Dev);
    comp.comp();
}
source

fn create_boxed(&mut self) -> Box<Self::Impl>

Implementors§