Macro sp_core::generate_feature_enabled_macro

source ·
macro_rules! generate_feature_enabled_macro {
    ( $macro_name:ident, $feature_name:meta, $d:tt ) => { ... };
}
Expand description

Generates a macro for checking if a certain feature is enabled.

These feature checking macros can be used to conditionally enable/disable code in a dependent crate based on a feature in the crate where the macro is called.

§Example

 sp_core::generate_feature_enabled_macro!(check_std_is_enabled, feature = "std", $);
 sp_core::generate_feature_enabled_macro!(check_std_or_serde_is_enabled, any(feature = "std", feature = "serde"), $);

 // All the code passed to the macro will then conditionally compiled based on the features
 // activated for the crate where the macro was generated.
 check_std_is_enabled! {
     struct StdEnabled;
 }