#[register_default_impl]
Expand description

Attach this attribute to an impl statement that you want to use with #[derive_impl(..)].

You must also provide an identifier/name as the attribute’s argument. This is the name you must provide to #[derive_impl(..)] when you import this impl via the default_impl_path argument. This name should be unique at the crate-level.

Example

pub struct ExampleTestDefaultConfig;

#[register_default_impl(ExampleTestDefaultConfig)]
impl DefaultConfig for ExampleTestDefaultConfig {
	type Version = ();
	type BlockWeights = ();
	type BlockLength = ();
	...
	type SS58Prefix = ();
	type MaxConsumers = frame_support::traits::ConstU32<16>;
}

Advanced Usage

This macro acts as a thin wrapper around macro_magic’s #[export_tokens]. See the docs here for more info.

There are some caveats when applying a use statement to bring a #[register_default_impl] item into scope. If you have a #[register_default_impl] defined in my_crate::submodule::MyItem, it is currently not sufficient to do something like:

use my_crate::submodule::MyItem;
#[derive_impl(MyItem as Whatever)]

This will fail with a mysterious message about __export_tokens_tt_my_item not being defined.

You can, however, do any of the following:

// partial path works
use my_crate::submodule;
#[derive_impl(submodule::MyItem as Whatever)]
// full path works
#[derive_impl(my_crate::submodule::MyItem as Whatever)]
// wild-cards work
use my_crate::submodule::*;
#[derive_impl(MyItem as Whatever)]