chore(style): fix linting (#35)

This commit is contained in:
Anton Suprunchuk
2024-01-11 20:00:21 +07:00
committed by GitHub
parent ee398bf46b
commit afe123e024
7 changed files with 10 additions and 17 deletions

View File

@@ -1,7 +1,5 @@
pub use core::prelude::v1::*;
pub use alloc::borrow::ToOwned;
pub use alloc::boxed::Box;
pub use alloc::string::{String, ToString};
pub use alloc::vec::Vec;
@@ -9,5 +7,3 @@ pub use alloc::format;
pub use alloc::vec;
// Those are exported by default in the std prelude in Rust 2021
pub use core::convert::{TryFrom, TryInto};
pub use core::iter::FromIterator;

View File

@@ -32,8 +32,7 @@ impl MerkleProofSerializer for DirectHashesOrder {
let slice = bytes
.get(slice_start..slice_end)
.ok_or_else(Error::vec_to_hash_conversion_error)?;
let vec =
Vec::<u8>::try_from(slice).map_err(|_| Error::vec_to_hash_conversion_error())?;
let vec = Vec::from(slice);
match T::Hash::try_from(vec) {
Ok(val) => proof_hashes_slices.push(val),
Err(_) => return Err(Error::vec_to_hash_conversion_error()),

View File

@@ -34,8 +34,7 @@ impl MerkleProofSerializer for ReverseHashesOrder {
let slice = bytes
.get(slice_start..slice_end)
.ok_or_else(Error::vec_to_hash_conversion_error)?;
let vec =
Vec::<u8>::try_from(slice).map_err(|_| Error::vec_to_hash_conversion_error())?;
let vec = Vec::from(slice);
match T::Hash::try_from(vec) {
Ok(val) => proof_hashes_slices.push(val),
Err(_) => return Err(Error::vec_to_hash_conversion_error()),

View File

@@ -15,5 +15,5 @@ pub fn to_hex_string<T: Clone + Into<Vec<u8>>>(bytes: &T) -> String {
/// containing the difference. This function preserves the first
/// vector order.
pub fn difference<T: Clone + PartialEq>(a: &[T], b: &[T]) -> Vec<T> {
a.iter().cloned().filter(|x| !b.contains(x)).collect()
a.iter().filter(|&x| !b.contains(x)).cloned().collect()
}

View File

@@ -27,7 +27,7 @@ fn combine<T: Clone>(active: Vec<T>, rest: Vec<T>, mut combinations: Vec<Vec<T>>
} else {
let mut next = active.clone();
if let Some(first) = rest.get(0) {
if let Some(first) = rest.first() {
next.push(first.clone());
}
@@ -123,8 +123,7 @@ pub fn setup_proof_test_cases() -> Vec<ProofTestCases> {
.collect();
let merkle_tree = MerkleTree::<Sha256>::from_leaves(&leaves);
let case = ProofTestCases { merkle_tree, cases };
case
ProofTestCases { merkle_tree, cases }
})
.collect()
}

View File

@@ -17,7 +17,7 @@ pub mod root {
let leaves_to_prove: Vec<[u8; 32]> = indices_to_prove
.iter()
.map(|i| leaf_hashes.get(*i).unwrap().clone())
.map(|i| *leaf_hashes.get(*i).unwrap())
.collect();
let merkle_tree = MerkleTree::<Sha256>::from_leaves(&test_data.leaf_hashes);
@@ -173,7 +173,7 @@ pub mod to_bytes {
}
pub mod from_bytes {
use crate::common;
use rs_merkle::{algorithms::Sha256, Error, MerkleProof};
#[test]

View File

@@ -67,7 +67,7 @@ pub mod proof {
pub mod commit {
use crate::common;
use rs_merkle::{algorithms::Sha256, Error, Hasher, MerkleTree};
use rs_merkle::{algorithms::Sha256, Hasher, MerkleTree};
#[test]
pub fn should_give_correct_root_after_commit() {
@@ -78,7 +78,7 @@ pub mod commit {
// Passing empty vec to create an empty tree
let mut merkle_tree = MerkleTree::<Sha256>::from_leaves(&vec);
let merkle_tree2 = MerkleTree::<Sha256>::from_leaves(&leaf_hashes);
let merkle_tree2 = MerkleTree::<Sha256>::from_leaves(leaf_hashes);
// Adding leaves
merkle_tree.append(leaf_hashes.clone().as_mut());
let root = merkle_tree.uncommitted_root_hex();
@@ -197,7 +197,7 @@ pub mod commit {
}
pub mod rollback {
use crate::common;
use rs_merkle::{algorithms::Sha256, Hasher, MerkleTree};
#[test]