Adds with_pair! macro to application-crypto (#4885)

* Adds `with_pair!` macro to application-crypto

This macro will "generate" the given code only when the crypto pair is
available. So, when either the `std` or the `full_crypto` feature is
enabled.

* Fix example
This commit is contained in:
Bastian Köcher
2020-02-14 15:46:41 +01:00
committed by GitHub
parent d3a3e288b6
commit 91989cab46
6 changed files with 54 additions and 24 deletions
@@ -436,3 +436,30 @@ macro_rules! wrap {
}
}
}
/// Generate the given code if the pair type is available.
///
/// The pair type is available when `feature = "std"` || `feature = "full_crypto"`.
///
/// # Example
///
/// ```
/// sp_application_crypto::with_pair! {
/// pub type Pair = ();
/// }
/// ```
#[macro_export]
#[cfg(any(feature = "std", feature = "full_crypto"))]
macro_rules! with_pair {
( $( $def:tt )* ) => {
$( $def )*
}
}
#[doc(hidden)]
#[macro_export]
#[cfg(all(not(feature = "std"), not(feature = "full_crypto")))]
macro_rules! with_pair {
( $( $def:tt )* ) => {}
}