Expand description

Easy DI is dependency injection container for Rust.

Setup:

use std::sync::Arc;
use easy_di::{Container, ServiceProvider};

pub trait Animal {
    fn make_sound(&self);
}

#[derive(Clone)]
struct Dog;
impl Animal for Dog {
    fn make_sound(&self) {
        println!("woof woof!")
    }
}

let mut container = Container::new();
let animal: Arc<dyn Animal + Sync + Send> = Arc::new(Dog);
container.inject(animal);

let animal2 = container.find::<Arc<dyn Animal + Sync + Send>>();
animal2.unwrap().make_sound();

Re-exports

pub use service_provider::ServiceProvider;

Modules

Structs

Enums