Misc clippy fixes

This commit is contained in:
Luke Parker
2025-09-03 06:10:54 -04:00
parent 2032cf355f
commit a2209dd6ff
5 changed files with 19 additions and 6 deletions

View File

@@ -95,10 +95,10 @@ impl scale::EncodeLike<sp_core::H256> for &BlockHash {}
pub mod prelude {
pub use crate::{BlockNumber, BlockHash};
pub use crate::constants::*;
pub use crate::address::*;
pub use crate::address::{SeraiAddress, ExternalAddress};
pub use crate::coin::*;
pub use crate::balance::*;
pub use crate::network_id::*;
pub use crate::validator_sets::*;
pub use crate::validator_sets::{Session, ValidatorSet, ExternalValidatorSet, Slash, SlashReport};
pub use crate::instructions::*;
}

View File

@@ -16,6 +16,12 @@ pub struct UnbalancedMerkleTree {
pub root: [u8; 32],
}
impl Default for UnbalancedMerkleTree {
fn default() -> Self {
Self::EMPTY
}
}
impl UnbalancedMerkleTree {
/// An empty Merkle tree.
pub const EMPTY: Self = Self { root: [0; 32] };
@@ -77,10 +83,17 @@ pub struct IncrementalUnbalancedMerkleTree {
branches: Vec<(u64, [u8; 32])>,
}
#[allow(clippy::derivable_impls)]
impl Default for IncrementalUnbalancedMerkleTree {
fn default() -> Self {
Self { branches: Vec::new() }
}
}
impl IncrementalUnbalancedMerkleTree {
/// Create a new incrementally-created unbalanced merkle tree.
pub fn new() -> Self {
Self { branches: Vec::new() }
Self::default()
}
/// Reduce the incremental tree.

View File

@@ -93,9 +93,8 @@ impl ExternalValidatorSet {
// Check we have room to encode into `res`, using the approximate `size_of` for the max size of
// the serialization
const BYTES_FOR_SET: usize = 32 - (1 + DST.len());
const _ASSERT_MORE_BYTES_THAN_SIZE: [();
BYTES_FOR_SET - core::mem::size_of::<ExternalValidatorSet>()] = [(); _];
32 - (1 + DST.len()) - core::mem::size_of::<ExternalValidatorSet>()] = [(); _];
let encoded = borsh::to_vec(&self).unwrap();
res[(1 + DST.len()) .. (1 + DST.len() + encoded.len())].copy_from_slice(&encoded);