diff --git a/bls/src/types/signature.rs b/bls/src/types/signature.rs index 109ea33da6..36bc6fb326 100644 --- a/bls/src/types/signature.rs +++ b/bls/src/types/signature.rs @@ -111,7 +111,7 @@ impl Signature { /// validator's signature by its number of slots. #[must_use] pub fn multiply(&self, x: u16) -> Self { - let signature = self.signature.mul(&[x as u64]); + let signature = self.signature.mul([x as u64]); Signature { signature, compressed: CompressedSignature::from(signature), diff --git a/keys/src/public_key.rs b/keys/src/public_key.rs index e1e99fd4c2..e5586a4197 100644 --- a/keys/src/public_key.rs +++ b/keys/src/public_key.rs @@ -151,7 +151,6 @@ impl SerializeContent for PublicKey { impl Hash for PublicKey {} -#[allow(clippy::derive_hash_xor_eq)] impl std::hash::Hash for PublicKey { fn hash(&self, state: &mut H) { std::hash::Hash::hash(self.as_bytes(), state); diff --git a/lib/src/config/config_file/mod.rs b/lib/src/config/config_file/mod.rs index cf812fc1c6..8dc3c478fc 100644 --- a/lib/src/config/config_file/mod.rs +++ b/lib/src/config/config_file/mod.rs @@ -169,10 +169,11 @@ pub struct ConsensusSettings { pub min_peers: Option, } -#[derive(Deserialize, Debug, Copy, Clone, PartialEq, Eq)] +#[derive(Clone, Copy, Deserialize, Debug, Default, Eq, PartialEq)] #[serde(rename_all = "lowercase")] /// Synchronization mode used by the client based upon its client type pub enum SyncMode { + #[default] /// Synchronization mode used by History nodes (full transaction history is maintained) History, /// Full Nodes. They use LightMacroSync + State Sync to reach consensus @@ -180,11 +181,6 @@ pub enum SyncMode { /// Light nodes use LightMacroSync + BlockLiveSync to reach consensus Light, } -impl Default for SyncMode { - fn default() -> Self { - SyncMode::History - } -} #[derive(Debug, Error)] #[error("Invalid sync mode: {0}")] @@ -213,7 +209,7 @@ impl From for config::SyncMode { } } -#[derive(Deserialize, Debug, Copy, Clone, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq)] #[serde(rename_all = "kebab-case")] // TODO: I think we can directly use `NetworkId` here pub enum Network { @@ -221,16 +217,11 @@ pub enum Network { Test, Dev, TestAlbatross, + #[default] DevAlbatross, UnitAlbatross, } -impl Default for Network { - fn default() -> Self { - Network::DevAlbatross - } -} - impl FromStr for Network { type Err = (); diff --git a/primitives/account/src/receipts.rs b/primitives/account/src/receipts.rs index 9695b75f8b..8ff61ee825 100644 --- a/primitives/account/src/receipts.rs +++ b/primitives/account/src/receipts.rs @@ -113,7 +113,6 @@ impl SerializeContent for Receipt { } } -#[allow(clippy::derive_hash_xor_eq)] // TODO: Shouldn't be necessary impl Hash for Receipt { fn hash(&self) -> H { let h = H::Builder::default(); diff --git a/primitives/block/src/macro_block.rs b/primitives/block/src/macro_block.rs index bd86cecdd4..6505b0021e 100644 --- a/primitives/block/src/macro_block.rs +++ b/primitives/block/src/macro_block.rs @@ -206,7 +206,6 @@ impl Message for MacroHeader { const PREFIX: u8 = PREFIX_TENDERMINT_PROPOSAL; } -#[allow(clippy::derive_hash_xor_eq)] // TODO: Shouldn't be necessary impl Hash for MacroHeader {} impl fmt::Display for MacroHeader { @@ -278,7 +277,6 @@ impl MacroBody { } } -#[allow(clippy::derive_hash_xor_eq)] // TODO: Shouldn't be necessary impl Hash for MacroBody {} #[derive(Error, Debug)] diff --git a/primitives/subscription/src/lib.rs b/primitives/subscription/src/lib.rs index 2d7ebe93d0..75aa67daff 100644 --- a/primitives/subscription/src/lib.rs +++ b/primitives/subscription/src/lib.rs @@ -5,10 +5,11 @@ use nimiq_keys::Address; use nimiq_primitives::coin::Coin; use nimiq_transaction::Transaction; -#[derive(Clone, Debug, Serialize, Deserialize)] +#[derive(Clone, Debug, Default, Deserialize, Serialize)] #[repr(u8)] pub enum Subscription { #[beserial(discriminant = 0)] + #[default] None, #[beserial(discriminant = 1)] Any, @@ -18,12 +19,6 @@ pub enum Subscription { MinFee(Coin), // Fee per byte } -impl Default for Subscription { - fn default() -> Self { - Subscription::None - } -} - impl Subscription { pub fn matches_block(&self) -> bool { !matches!(self, Subscription::None) diff --git a/primitives/transaction/src/account/htlc_contract.rs b/primitives/transaction/src/account/htlc_contract.rs index 2e8d0660b7..f3ff54f5ed 100644 --- a/primitives/transaction/src/account/htlc_contract.rs +++ b/primitives/transaction/src/account/htlc_contract.rs @@ -161,21 +161,18 @@ impl AccountTransactionVerification for HashedTimeLockedContractVerifier { } } -#[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Serialize, Deserialize, Display)] +#[derive( + Clone, Copy, Debug, Default, Deserialize, Display, Eq, Ord, PartialEq, PartialOrd, Serialize, +)] #[repr(u8)] #[cfg_attr(feature = "serde-derive", derive(serde::Serialize, serde::Deserialize))] pub enum HashAlgorithm { + #[default] Blake2b = 1, Sha256 = 3, } -impl Default for HashAlgorithm { - fn default() -> Self { - HashAlgorithm::Blake2b - } -} - -#[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)] #[repr(u8)] pub enum ProofType { RegularTransfer = 1, @@ -192,7 +189,7 @@ impl AnyHash { } } -#[derive(Default, Clone, Debug, Serialize, Deserialize)] +#[derive(Clone, Debug, Default, Deserialize, Serialize)] #[cfg_attr(feature = "serde-derive", derive(serde::Serialize, serde::Deserialize))] pub struct CreationTransactionData { pub sender: Address, diff --git a/spammer/src/main.rs b/spammer/src/main.rs index 7b8c9086e9..dfd031465d 100644 --- a/spammer/src/main.rs +++ b/spammer/src/main.rs @@ -392,7 +392,7 @@ async fn spam( SpamType::Vesting, ]; - let dist = WeightedIndex::new(&config.weights).unwrap(); + let dist = WeightedIndex::new(config.weights).unwrap(); let mut rng = thread_rng(); let new_count;