A more relaxed way to define DefaultConfig
for pallets
#5246
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.
The underlying problem is this:
In a given pallet, we want to provide defaults for (usually) all
type
s inTestDefaultConfig
, but forSolochainDefaultConfig
and such, we might want to provide defaults in only a subset of them.#4689 and #4965 and #4056 have all faces this issue one way or another.
What I have done here is a simple and near zero effort way to fix this. The compromise is that we use a bit more type-safety, but as long as we have at least one test for usage of each
register_default_impl
, we are good.The trick is to mark a type that is ambiguous as
#[no_default_bound]
. Then, we can provide a default that actually works inTestDefaultConfig
, and one that does not in production.The error message will look something like this: