A dependency injection library for Rust.
toml
[dependencies]
dilib = "0.1.3-alpha"
```rust use std::sync::Mutex; use dilib::*;
struct GetNumber(u32);
struct Counter { val: u32, }
let mut container = Container::new(); container.addscoped(|| String::from("Hello, world!")); container.addscopedwithname("42", || GetNumber(42)); container.addscopedwithname("102", || GetNumber(102)); container.addsingleton(Mutex::new(Counter { val: 0 }));
let mut counter = container.get_singleton::
asserteq!(container.getscoped::
Requires derive
feature.
```rust use std::sync::Mutex; use dilib::*;
struct Counter {
#[inject(default="Counter")]
label: String,
val: Singleton
let mut container = Container::new();
container.addsingleton(Mutex::new(0usize));
container.add_deps::
let c1 = container.get_scoped::
let c2 = container.getscoped::