From 4b58f0ac69cf465a8c5616cae3fe9dacee047b09 Mon Sep 17 00:00:00 2001 From: giuseppere Date: Thu, 19 Dec 2024 16:05:19 +0100 Subject: [PATCH] using `default()` to create empty `WeakBoundedVec` --- substrate/frame/staking/src/tests.rs | 7 ++----- substrate/primitives/staking/src/lib.rs | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/substrate/frame/staking/src/tests.rs b/substrate/frame/staking/src/tests.rs index 8422b355dad4..aa35d092fbb8 100644 --- a/substrate/frame/staking/src/tests.rs +++ b/substrate/frame/staking/src/tests.rs @@ -6616,10 +6616,7 @@ fn should_retain_era_info_only_upto_history_depth() { for page in 0..3 { ErasStakersPaged::::insert( (era, &validator_stash, page), - ExposurePage { - page_total: 100, - others: WeakBoundedVec::force_from(vec![], None), - }, + ExposurePage { page_total: 100, others: WeakBoundedVec::default() }, ); } } @@ -8631,7 +8628,7 @@ mod getters { // given let era: EraIndex = 12; let account_id: mock::AccountId = 1; - let rewards = WeakBoundedVec::force_from(vec![], None); + let rewards = WeakBoundedVec::default(); ClaimedRewards::::insert(era, account_id, rewards.clone()); // when diff --git a/substrate/primitives/staking/src/lib.rs b/substrate/primitives/staking/src/lib.rs index a9e14dc5858a..82d9b25fecbc 100644 --- a/substrate/primitives/staking/src/lib.rs +++ b/substrate/primitives/staking/src/lib.rs @@ -401,7 +401,7 @@ impl, MaxExposurePageSize, - > = WeakBoundedVec::force_from(vec![], None); + > = WeakBoundedVec::default(); for individual in chunk.iter() { page_total.saturating_accrue(individual.value); let _ = others.try_push(IndividualExposure { @@ -444,10 +444,7 @@ pub struct ExposurePage< impl> Default for ExposurePage { fn default() -> Self { - ExposurePage { - page_total: Default::default(), - others: WeakBoundedVec::force_from(vec![], None), - } + ExposurePage { page_total: Default::default(), others: WeakBoundedVec::default() } } }