From c38136b6bcd20f9ee15f6305a6a10b87fb4dafad Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Tue, 22 Dec 2020 14:02:31 +1100 Subject: [PATCH] Use for loop instead of map Currently we are misusing `map` on an iterator to loop `n` times, additionally the assertion is pointless. Use a for loop and assert against the length of the set. --- src/key.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/key.rs b/src/key.rs index abcd9a7..696cadc 100644 --- a/src/key.rs +++ b/src/key.rs @@ -762,13 +762,13 @@ mod test { let s = Secp256k1::new(); let mut set = HashSet::new(); const COUNT : usize = 1024; - let count = (0..COUNT).map(|_| { + for _ in 0..COUNT { let (_, pk) = s.generate_keypair(&mut thread_rng()); let hash = hash(&pk); assert!(!set.contains(&hash)); set.insert(hash); - }).count(); - assert_eq!(count, COUNT); + }; + assert_eq!(set.len(), COUNT); } #[test]