-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove module public exports ordering limitation #37
Comments
Do I understand correctly that this is the reason why following code does not work? use bar::BarModule;
use foo::FooModule;
use nject::{injectable, provider};
mod foo {
use nject::{injectable, module};
pub struct Foo;
#[injectable]
#[module]
pub struct FooModule(
#[inject(|| Foo)]
#[export]
Foo,
);
}
mod bar {
use nject::{injectable, module};
use crate::foo::Foo;
#[injectable]
pub struct Bar {
foo: Foo,
}
#[injectable]
#[module]
pub struct BarModule(#[export] Bar);
}
fn main() {
#[provider]
struct InitProvider;
#[injectable]
#[provider]
struct Provider(#[import] FooModule, #[import] BarModule);
let provider: Provider = InitProvider.provide();
} I have encountered this why trying divide my code into multiple dependent modules. Not exactly sure if it is my bad understanding of how modules should be used, or an issue. I can work it around by "staging" providers which leads to ridiculous code like bellow: fn main() {
#[provider]
struct InitProvider;
#[injectable]
#[provider]
struct Provider0(#[import] FooModule);
#[injectable]
#[provider]
struct Provider1(#[import] FooModule, #[import] BarModule);
let provider0: Provider0 = InitProvider.provide();
let provider1: Provider0 = InitProvider.provide();
} |
Hi @majkrzak, Unfortunately, this issue won't solve your problem. The only way to make it work right now is by staging like you mentioned or manually injecting modules in the provider. |
Could be fixed by: rust-lang/rust#44034
The text was updated successfully, but these errors were encountered: