Expand description

An attribute macro that can be attached to a module declaration. Doing so will Imports the contents of the specified external pallet section that was defined previously using #[pallet_section].


pub mod pallet {
    // ...

where some_section was defined elsewhere via:

pub mod some_section {
    // ...

This will result in the contents of some_section being verbatim imported into the pallet above. Note that since the tokens for some_section are essentially copy-pasted into the target pallet, you cannot refer to imports that don’t also exist in the target pallet, but this is easily resolved by including all relevant use statements within your pallet section, so they are imported as well, or by otherwise ensuring that you have the same imports on the target pallet.

It is perfectly permissible to import multiple pallet sections into the same pallet, which can be done by having multiple #[import_section(something)] attributes attached to the pallet.

Note that sections are imported by their module name/ident, and should be referred to by their full path from the perspective of the target pallet.