Add DefaultNoBound (#8542)

* Add DefaultNoBound

* Add tests

* Fix
This commit is contained in:
Kian Paimani
2021-04-08 13:23:55 +02:00
committed by GitHub
parent c04b44b0a3
commit 524fc7d500
6 changed files with 204 additions and 6 deletions
+19
View File
@@ -560,6 +560,25 @@ pub use frame_support_procedural::PartialEqNoBound;
/// ```
pub use frame_support_procedural::DebugNoBound;
/// Derive [`Default`] but do not bound any generic.
///
/// This is useful for type generic over runtime:
/// ```
/// # use frame_support::DefaultNoBound;
/// # use core::default::Default;
/// trait Config {
/// type C: Default;
/// }
///
/// // Foo implements [`Default`] because `C` bounds [`Default`].
/// // Otherwise compilation will fail with an output telling `c` doesn't implement [`Default`].
/// #[derive(DefaultNoBound)]
/// struct Foo<T: Config> {
/// c: T::C,
/// }
/// ```
pub use frame_support_procedural::DefaultNoBound;
/// Assert the annotated function is executed within a storage transaction.
///
/// The assertion is enabled for native execution and when `debug_assertions` are enabled.