]> Untitled Git - bdk/commitdiff
Use count instead of collect and len
authorTobin Harding <me@tobin.cc>
Wed, 23 Dec 2020 03:07:09 +0000 (14:07 +1100)
committerTobin Harding <me@tobin.cc>
Wed, 24 Feb 2021 02:30:47 +0000 (13:30 +1100)
Clippy emits warning:

warning: avoid using `collect()` when not needed

As suggested by clippy just use `count` directly on the iterator instead
of `collect` followed by `len`.

src/wallet/tx_builder.rs

index 35c7d0733ee7218f608fadbd723888f177fa367f..9a9b8d2ea3b3032f28cb01d9a992518597440f4d 100644 (file)
@@ -736,9 +736,9 @@ mod test {
         let filtered = get_test_utxos()
             .into_iter()
             .filter(|u| change_spend_policy.is_satisfied_by(u))
-            .collect::<Vec<_>>();
+            .count();
 
-        assert_eq!(filtered.len(), 2);
+        assert_eq!(filtered, 2);
     }
 
     #[test]