Browse Source

satisfy clippy

develop
Kyrylo Stepanov 2 years ago
parent
commit
fddc20125b

+ 2
- 2
common-api/src/crypto/ed25519.rs View File

80
 
80
 
81
 // This `Hash` implementation is safe since it retains the property
81
 // This `Hash` implementation is safe since it retains the property
82
 // `k1 == k2 ⇒ hash(k1) == hash(k2)`.
82
 // `k1 == k2 ⇒ hash(k1) == hash(k2)`.
83
-#[allow(clippy::derive_hash_xor_eq)]
83
+#[allow(clippy::derived_hash_with_manual_eq)]
84
 impl Hash for Ed25519PublicKey {
84
 impl Hash for Ed25519PublicKey {
85
     fn hash<H: Hasher>(&self, state: &mut H) {
85
     fn hash<H: Hasher>(&self, state: &mut H) {
86
         state.write_u8(0u8);
86
         state.write_u8(0u8);
197
     }
197
     }
198
 }
198
 }
199
 
199
 
200
-#[allow(clippy::derive_hash_xor_eq)]
200
+#[allow(clippy::derived_hash_with_manual_eq)]
201
 impl Hash for Ed25519Signature {
201
 impl Hash for Ed25519Signature {
202
     fn hash<H: Hasher>(&self, state: &mut H) {
202
     fn hash<H: Hasher>(&self, state: &mut H) {
203
         self.to_bytes().hash(state);
203
         self.to_bytes().hash(state);

+ 4
- 14
near-primitives-light/src/transaction.rs View File

257
 }
257
 }
258
 
258
 
259
 /// The status of execution for a transaction or a receipt.
259
 /// The status of execution for a transaction or a receipt.
260
-#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Clone)]
260
+#[derive(Default, BorshSerialize, BorshDeserialize, PartialEq, Eq, Clone)]
261
 pub enum ExecutionStatus {
261
 pub enum ExecutionStatus {
262
     /// The execution is pending or unknown.
262
     /// The execution is pending or unknown.
263
+    #[default]
263
     Unknown,
264
     Unknown,
264
     /// The execution has failed with the given execution error.
265
     /// The execution has failed with the given execution error.
265
     Failure(Box<TxExecutionError>),
266
     Failure(Box<TxExecutionError>),
285
     }
286
     }
286
 }
287
 }
287
 
288
 
288
-impl Default for ExecutionStatus {
289
-    fn default() -> Self {
290
-        ExecutionStatus::Unknown
291
-    }
292
-}
293
-
294
 /// ExecutionOutcome for proof. Excludes logs and metadata
289
 /// ExecutionOutcome for proof. Excludes logs and metadata
295
 #[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Clone)]
290
 #[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Clone)]
296
 pub struct PartialExecutionOutcome {
291
 pub struct PartialExecutionOutcome {
371
     }
366
     }
372
 }
367
 }
373
 
368
 
374
-#[derive(BorshSerialize, BorshDeserialize, PartialEq, Clone, Eq, Debug)]
369
+#[derive(Default, BorshSerialize, BorshDeserialize, PartialEq, Clone, Eq, Debug)]
375
 pub enum ExecutionMetadata {
370
 pub enum ExecutionMetadata {
376
     // V1: Empty Metadata
371
     // V1: Empty Metadata
372
+    #[default]
377
     V1,
373
     V1,
378
 
374
 
379
     // V2: With ProfileData
375
     // V2: With ProfileData
380
     V2(ProfileData),
376
     V2(ProfileData),
381
 }
377
 }
382
 
378
 
383
-impl Default for ExecutionMetadata {
384
-    fn default() -> Self {
385
-        ExecutionMetadata::V1
386
-    }
387
-}
388
-
389
 impl fmt::Debug for ExecutionOutcome {
379
 impl fmt::Debug for ExecutionOutcome {
390
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
380
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
391
         f.debug_struct("ExecutionOutcome")
381
         f.debug_struct("ExecutionOutcome")

+ 2
- 7
near-primitives-light/src/types.rs View File

12
 pub type StateRoot = CryptoHash;
12
 pub type StateRoot = CryptoHash;
13
 
13
 
14
 /// Different types of finality.
14
 /// Different types of finality.
15
-#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
15
+#[derive(Default, Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
16
 pub enum Finality {
16
 pub enum Finality {
17
     #[serde(rename = "optimistic")]
17
     #[serde(rename = "optimistic")]
18
     None,
18
     None,
19
     #[serde(rename = "near-final")]
19
     #[serde(rename = "near-final")]
20
     DoomSlug,
20
     DoomSlug,
21
+    #[default]
21
     #[serde(rename = "final")]
22
     #[serde(rename = "final")]
22
     Final,
23
     Final,
23
 }
24
 }
24
 
25
 
25
-impl Default for Finality {
26
-    fn default() -> Self {
27
-        Finality::Final
28
-    }
29
-}
30
-
31
 #[derive(Debug, Serialize, Deserialize)]
26
 #[derive(Debug, Serialize, Deserialize)]
32
 pub struct AccountWithPublicKey {
27
 pub struct AccountWithPublicKey {
33
     pub account_id: AccountId,
28
     pub account_id: AccountId,

+ 4
- 7
near-primitives-light/src/views.rs View File

596
 }
596
 }
597
 
597
 
598
 #[allow(clippy::large_enum_variant)]
598
 #[allow(clippy::large_enum_variant)]
599
-#[derive(BorshSerialize, BorshDeserialize, Serialize, Deserialize, PartialEq, Eq, Clone)]
599
+#[derive(
600
+    Default, BorshSerialize, BorshDeserialize, Serialize, Deserialize, PartialEq, Eq, Clone,
601
+)]
600
 pub enum FinalExecutionStatus {
602
 pub enum FinalExecutionStatus {
601
     /// The execution has not yet started.
603
     /// The execution has not yet started.
604
+    #[default]
602
     NotStarted,
605
     NotStarted,
603
     /// The execution has started and still going.
606
     /// The execution has started and still going.
604
     Started,
607
     Started,
621
     }
624
     }
622
 }
625
 }
623
 
626
 
624
-impl Default for FinalExecutionStatus {
625
-    fn default() -> Self {
626
-        FinalExecutionStatus::NotStarted
627
-    }
628
-}
629
-
630
 #[allow(clippy::large_enum_variant)]
627
 #[allow(clippy::large_enum_variant)]
631
 #[derive(BorshSerialize, BorshDeserialize, Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
628
 #[derive(BorshSerialize, BorshDeserialize, Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
632
 pub enum ServerError {
629
 pub enum ServerError {

Loading…
Cancel
Save