pallet macro: easier syntax for #[pallet::pallet] with struct Pallet<T>(_) (#8091)

This commit is contained in:
Guillaume Thiolliere
2021-02-10 10:27:05 +01:00
committed by GitHub
parent 2d31af3eb6
commit e78d139676
13 changed files with 30 additions and 19 deletions
+5 -4
View File
@@ -1141,7 +1141,7 @@ pub mod pallet_prelude {
/// Item must be defined as followed:
/// ```ignore
/// #[pallet::pallet]
/// pub struct Pallet<T>(PhantomData<T>);
/// pub struct Pallet<T>(_);
/// ```
/// I.e. a regular struct definition named `Pallet`, with generic T and no where clause.
///
@@ -1150,7 +1150,7 @@ pub mod pallet_prelude {
/// ```ignore
/// #[pallet::pallet]
/// #[pallet::generate_store(pub(super) trait Store)]
/// pub struct Pallet<T>(PhantomData<T>);
/// pub struct Pallet<T>(_);
/// ```
/// More precisely the store trait contains an associated type for each storage. It is implemented
/// for `Pallet` allowing to access the storage from pallet struct.
@@ -1169,6 +1169,7 @@ pub mod pallet_prelude {
/// frame_support::RuntimeDebugNoBound,
/// )]
/// ```
/// and replace the type `_` by `PhantomData<T>`.
///
/// It implements on pallet:
/// * [`traits::GetPalletVersion`]
@@ -1602,7 +1603,7 @@ pub mod pallet_prelude {
/// // Define the pallet struct placeholder, various pallet function are implemented on it.
/// #[pallet::pallet]
/// #[pallet::generate_store(pub(super) trait Store)]
/// pub struct Pallet<T>(PhantomData<T>);
/// pub struct Pallet<T>(_);
///
/// // Implement the pallet hooks.
/// #[pallet::hooks]
@@ -1920,7 +1921,7 @@ pub mod pallet_prelude {
/// #[pallet::generate_store($visibility_of_trait_store trait Store)]
/// // NOTE: if the visibility of trait store is private but you want to make it available
/// // in super, then use `pub(super)` or `pub(crate)` to make it available in crate.
/// pub struct Pallet<T>(PhantomData<T>);
/// pub struct Pallet<T>(_);
/// // pub struct Pallet<T, I = ()>(PhantomData<T>); // for instantiable pallet
/// }
/// ```