Skip to content

Commit

Permalink
using default() to create empty WeakBoundedVec
Browse files Browse the repository at this point in the history
  • Loading branch information
re-gius committed Dec 19, 2024
1 parent 0d47dc5 commit 4b58f0a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
7 changes: 2 additions & 5 deletions substrate/frame/staking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6616,10 +6616,7 @@ fn should_retain_era_info_only_upto_history_depth() {
for page in 0..3 {
ErasStakersPaged::<Test>::insert(
(era, &validator_stash, page),
ExposurePage {
page_total: 100,
others: WeakBoundedVec::force_from(vec![], None),
},
ExposurePage { page_total: 100, others: WeakBoundedVec::default() },
);
}
}
Expand Down Expand Up @@ -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::<Test>::insert(era, account_id, rewards.clone());

// when
Expand Down
7 changes: 2 additions & 5 deletions substrate/primitives/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ impl<AccountId: Clone, Balance: HasCompact + AtLeast32BitUnsigned + Copy + MaxEn
let mut others: WeakBoundedVec<
IndividualExposure<AccountId, Balance>,
MaxExposurePageSize,
> = WeakBoundedVec::force_from(vec![], None);
> = WeakBoundedVec::default();
for individual in chunk.iter() {
page_total.saturating_accrue(individual.value);
let _ = others.try_push(IndividualExposure {
Expand Down Expand Up @@ -444,10 +444,7 @@ pub struct ExposurePage<

impl<A, B: Default + HasCompact + MaxEncodedLen, C: Get<u32>> Default for ExposurePage<A, B, C> {
fn default() -> Self {
ExposurePage {
page_total: Default::default(),
others: WeakBoundedVec::force_from(vec![], None),
}
ExposurePage { page_total: Default::default(), others: WeakBoundedVec::default() }
}
}

Expand Down

0 comments on commit 4b58f0a

Please sign in to comment.