-
Notifications
You must be signed in to change notification settings - Fork 0
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
Example prevent-circular: Cannot resolve binding #1
Comments
This is the expected behaviour of this example. Should i maybe add comments to explain it? |
Oh, I see, so it's expected, I think we can add a comment in the code 😅 Btw, how can I bind Bar to Bar (without a trait) Something like:
I got an error:
Or do I have to use the factory feature? |
I honestly haven't though much about that use case. Using a trait should be preferred in my opinion. But if you for any reason would want to, you could use a default factory |
So my codebase has a global Config struct -> it doesn't have any methods (so no trait) Other services will use that global config This workflow is very easy to do in Go (Uber Fx or Google wire) Could it be achievable without using the factory? (because of Rust nightly) |
I realize now that it actually should be possible to bind a struct to itself. So i have no idea why it doesn't work. I will look into it a bit later today. |
Basically what Syrette does deep down is it downcasts types using the And the
So it would maybe be if But as i said, i will look into this later. I just wanted to quickly throw this out there. |
I found the problem and fixed it in e282375. It was because no interface was being declared. The |
Oh, and i added some comments to the prevent-circular example in 488faf9. |
Thank you so much for the help! :) |
Thank you so much @HampusMat This is the best DI lib. I've already starred your repo |
Btw, I think we also need to update: Syrette/src/di_container/asynchronous/mod.rs Line 249 in 3c993aa
|
Why exactly? I can't see how that line would cause any problems. |
Yes, I think right now we point to a struct directly, but the param requires Send + Sync File to reproduce: |
Version: 0.4.1
Problem:
Error: BindingResolveFailed { reason: ResolveFailed { reason: BindingResolveFailed { reason: ResolveFailed { reason: BindingResolveFailed { reason: DetectedCircular { dependency_history: DependencyHistory { inner: ["creditor::Foo", "creditor::Bar", "creditor::Foo"] } }, interface: "creditor::Foo" }, affected: "creditor::Bar" }, interface: "creditor::Bar" }, affected: "creditor::Foo" }, interface: "creditor::Foo" }
How to reproduce: This is the code I copied exactly from the example (https://git.hampusmat.com/syrette/tree/examples/prevent-circular)
The text was updated successfully, but these errors were encountered: