Attribute Macro frame_support_procedural::type_value
source · #[type_value]Expand description
The #[pallet::type_value] attribute lets you define a struct implementing the Get trait
to ease the use of storage types. This attribute is meant to be used alongside
#[pallet::storage] to define a storage’s default value. This attribute
can be used multiple times.
Item must be defined as:
ⓘ
#[pallet::type_value]
fn $MyDefaultName<$some_generic>() -> $default_type $optional_where_clause { $expr }I.e.: a function definition with generics none or T: Config and a returned type.
E.g.:
ⓘ
#[pallet::type_value]
fn MyDefault<T: Config>() -> T::Balance { 3.into() }Macro expansion
The macro renames the function to some internal name, generates a struct with the original
name of the function and its generic, and implements Get<$ReturnType> by calling the user
defined function.