Skip to content
Snippets Groups Projects
Commit ad9624bf authored by Éloïs's avatar Éloïs
Browse files

[style] tests-tools: comply clippy

parent 313edd85
No related branches found
No related tags found
1 merge request!109Resolve "Fork resolution algorithm"
......@@ -19,7 +19,7 @@ use dup_crypto::hashs::Hash;
/// Generate mock hash from one character
pub fn hash(character: char) -> Hash {
let str_hash: String = (0..64).into_iter().map(|_| character).collect();
let str_hash: String = (0..64).map(|_| character).collect();
Hash::from_hex(&str_hash).expect("Fail to create hash !")
}
......
......@@ -21,7 +21,6 @@ use dubp_documents::{BlockId, Blockstamp};
/// Generate n mock blockstamps
pub fn generate_blockstamps(n: usize) -> Vec<Blockstamp> {
(0..n)
.into_iter()
.map(|i| Blockstamp {
id: BlockId(i as u32),
hash: BlockHash(dup_crypto_tests_tools::mocks::hash_from_byte(
......
......@@ -19,7 +19,7 @@ use std::collections::HashMap;
use std::hash::Hash;
/// Returns true if both slices contain the same elements but not necessarily in the same order
pub fn slice_same_elems<T: Hash + Eq + Clone>(a: &[T], b: &[T]) -> bool {
pub fn slice_same_elems<T: Clone + Eq + Hash>(a: &[T], b: &[T]) -> bool {
if a.len() != b.len() {
return false;
}
......@@ -39,9 +39,9 @@ pub fn slice_same_elems<T: Hash + Eq + Clone>(a: &[T], b: &[T]) -> bool {
true
}
fn find_element_in_slice<T: Hash + Eq>(s: &[T], e: &T) -> Option<usize> {
for i in 0..s.len() {
if s[i] == *e {
fn find_element_in_slice<T: Clone + Eq + Hash>(s: &[T], x: &T) -> Option<usize> {
for (i, e) in s.iter().enumerate() {
if *e == *x {
return Some(i);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment