portaldi

portaldi is a ergonomic, lightweight and compile-time dependency injection (DI) library for Rust.

Features

Example

```rust use portaldi::*;

[derive(DIPortal)]

struct Hoge { foo: DI, bar: DI, } impl Hoge { fn say_hello(&self) { println!("hello hoge < {}, {}", self.foo.hello(), self.bar.hello()) } }

pub trait FooI: DITarget { fn hello(&self) -> &str; }

[derive(DIPortal)]

[provide(FooI)]

struct Foo {}

impl FooI for Foo { fn hello(&self) -> &str { "hello foo" } }

[derive(DIPortal)]

struct Bar {}

impl Bar { fn hello(&self) -> &str { "hello bar" } }

fn main() { Hoge::di().say_hello(); }

```

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.