Skip to content

Simple dependency injection container for Rust.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

eisberg-labs/easy-di

Easy DI Continuous Integration cargo-badge license-badge

Simple dependency injection container for Rust.

Example

Code:

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!")
    }
}

fn main() {
    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();
}

Contributing

This project welcomes all kinds of contributions. No contribution is too small!

If you want to contribute to this project but don't know how to begin or if you need help with something related to this project, feel free to send me an email https://www.eisberg-labs.com/ (contact form at the bottom).

Some pointers on contribution are in Contributing.md

Code of Conduct

This project follows the Rust Code of Conduct.

License

Distributed under the terms of MIT license and Apache license.

About

Simple dependency injection container for Rust.

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages