diff --git a/src/prelude.rs b/src/prelude.rs index 8ab04f3..c0692bc 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -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; diff --git a/src/proof_serializers/direct_hashes_order.rs b/src/proof_serializers/direct_hashes_order.rs index 6ab9733..cd1cdf4 100644 --- a/src/proof_serializers/direct_hashes_order.rs +++ b/src/proof_serializers/direct_hashes_order.rs @@ -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::::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()), diff --git a/src/proof_serializers/reverse_hashes_order.rs b/src/proof_serializers/reverse_hashes_order.rs index 231c0c4..5f8a4d1 100644 --- a/src/proof_serializers/reverse_hashes_order.rs +++ b/src/proof_serializers/reverse_hashes_order.rs @@ -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::::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()), diff --git a/src/utils/collections.rs b/src/utils/collections.rs index 541573f..29a3d6c 100644 --- a/src/utils/collections.rs +++ b/src/utils/collections.rs @@ -15,5 +15,5 @@ pub fn to_hex_string>>(bytes: &T) -> String { /// containing the difference. This function preserves the first /// vector order. pub fn difference(a: &[T], b: &[T]) -> Vec { - a.iter().cloned().filter(|x| !b.contains(x)).collect() + a.iter().filter(|&x| !b.contains(x)).cloned().collect() } diff --git a/tests/common.rs b/tests/common.rs index 42f5a4d..37f521f 100644 --- a/tests/common.rs +++ b/tests/common.rs @@ -27,7 +27,7 @@ fn combine(active: Vec, rest: Vec, mut combinations: Vec> } 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 { .collect(); let merkle_tree = MerkleTree::::from_leaves(&leaves); - let case = ProofTestCases { merkle_tree, cases }; - case + ProofTestCases { merkle_tree, cases } }) .collect() } diff --git a/tests/merkle_proof_test.rs b/tests/merkle_proof_test.rs index b40b712..87e86ee 100644 --- a/tests/merkle_proof_test.rs +++ b/tests/merkle_proof_test.rs @@ -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::::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] diff --git a/tests/merkle_tree_test.rs b/tests/merkle_tree_test.rs index f3da7b6..e983fd6 100644 --- a/tests/merkle_tree_test.rs +++ b/tests/merkle_tree_test.rs @@ -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::::from_leaves(&vec); - let merkle_tree2 = MerkleTree::::from_leaves(&leaf_hashes); + let merkle_tree2 = MerkleTree::::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]