Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eisberg-labs/easy-di
Simple dependency injection container for Rust.
https://github.com/eisberg-labs/easy-di
dependency-injection ioc ioc-container
Last synced: about 1 month ago
JSON representation
Simple dependency injection container for Rust.
- Host: GitHub
- URL: https://github.com/eisberg-labs/easy-di
- Owner: eisberg-labs
- License: apache-2.0
- Created: 2022-07-22T15:44:48.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-20T19:52:41.000Z (over 1 year ago)
- Last Synced: 2024-10-29T02:08:06.853Z (about 2 months ago)
- Topics: dependency-injection, ioc, ioc-container
- Language: Rust
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE-APACHE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Easy DI [![Continuous Integration](https://github.com/eisberg-labs/easy-di/actions/workflows/ci.yml/badge.svg)](https://github.com/eisberg-labs/easy-di/actions/workflows/ci.yml) [![cargo-badge][]][cargo] [![license-badge][]][license]
> Simple dependency injection container for Rust.# Example
Code:```rust
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 = Arc::new(Dog);
container.inject(animal);
let animal2 = container.find::>();
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 (contact form at the bottom).Some pointers on contribution are in [Contributing.md](./CONTRIBUTING.md)
## Code of Conduct
This project follows the [Rust Code of Conduct](https://www.rust-lang.org/policies/code-of-conduct).
# License
Distributed under the terms of [MIT license](./LICENSE-MIT) and [Apache license](./LICENSE-APACHE).
[cargo-badge]: https://img.shields.io/crates/v/easy-di.svg?style=flat-square
[cargo]: https://crates.io/crates/easy-di
[license-badge]: https://img.shields.io/badge/license-MIT/Apache--2.0-lightgray.svg?style=flat-square
[license]: #license