Support provider checks in check_components!
#190
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR brings several improvements to the
check_components!macro.First, one can now use
check_components!to directly check for the implementation of a provider on a context. For example:This would desugar to something like:
On the other hand, without
#[check_providers], the check is done on theDelegateComponententry of the context. That is, with:would be expanded into:
The use of
#[check_providers]allows a provider to be checked directly, even when it is not wired with the context. For example, we can check on one or more alternative providers as follows:This allows one to first verify that a provider works with a context, before wiring it to the context. This would result in less confusing error, as compared to trying to implement and wire the provider at the same time.
#[check_providers]is also useful when higher order providers are used. When multiple providers are composed, and one of the provider implementation fails, the resulting error message don't usually show which sub-provider is failing. With#[check_providers], we can check each sub-provider or sub-combination to better determine the source of error.Aside from
#[check_providers],check_components!now allows multiple check blocks to be defined. With that, multiple check modes can be done at the same time withcheck_components!, such as: