pub struct Container<P> {
pub config: Config,
pub components: HashMap<TypeId, RcAny>,
/* private fields */
}
Fields§
§config: Config
§components: HashMap<TypeId, RcAny>
Implementations§
source§impl<P> Container<P>
impl<P> Container<P>
sourcepub fn new() -> Container<P>
pub fn new() -> Container<P>
Examples found in repository?
More examples
examples/3_inject_options_list.rs (line 96)
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();
}
Trait Implementations§
Auto Trait Implementations§
impl<P> !RefUnwindSafe for Container<P>
impl<P> !Send for Container<P>
impl<P> !Sync for Container<P>
impl<P> Unpin for Container<P>where
P: Unpin,
impl<P> !UnwindSafe for Container<P>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more