mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 13:31:10 +00:00
#[derive(MaxEncodedLen)] (#8737)
* impl #[derive(MaxEncodedLen)] for structs * impl #[derive(MaxEncodedLen)] for enums, unions * break long comments onto multiple lines * add doc for public item * add examples to macro documentation * move MaxEncodedLen macro docs, un-ignore doc-tests
This commit is contained in:
committed by
GitHub
parent
e1caa2979f
commit
17a1997d18
@@ -82,4 +82,32 @@ mod voting;
|
||||
pub use voting::{CurrencyToVote, SaturatingCurrencyToVote, U128CurrencyToVote};
|
||||
|
||||
mod max_encoded_len;
|
||||
// This looks like an overlapping import/export, but it isn't:
|
||||
// macros and traits live in distinct namespaces.
|
||||
pub use max_encoded_len::MaxEncodedLen;
|
||||
/// Derive [`MaxEncodedLen`][max_encoded_len::MaxEncodedLen].
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # use codec::Encode;
|
||||
/// # use frame_support::traits::MaxEncodedLen;
|
||||
/// #[derive(Encode, MaxEncodedLen)]
|
||||
/// struct TupleStruct(u8, u32);
|
||||
///
|
||||
/// assert_eq!(TupleStruct::max_encoded_len(), u8::max_encoded_len() + u32::max_encoded_len());
|
||||
/// ```
|
||||
///
|
||||
/// ```
|
||||
/// # use codec::Encode;
|
||||
/// # use frame_support::traits::MaxEncodedLen;
|
||||
/// #[derive(Encode, MaxEncodedLen)]
|
||||
/// enum GenericEnum<T> {
|
||||
/// A,
|
||||
/// B(T),
|
||||
/// }
|
||||
///
|
||||
/// assert_eq!(GenericEnum::<u8>::max_encoded_len(), u8::max_encoded_len() + u8::max_encoded_len());
|
||||
/// assert_eq!(GenericEnum::<u128>::max_encoded_len(), u8::max_encoded_len() + u128::max_encoded_len());
|
||||
/// ```
|
||||
pub use frame_support_procedural::MaxEncodedLen;
|
||||
|
||||
Reference in New Issue
Block a user