Skip to content

Commit 83f4274

Browse files
committed
chore: Apply Clippy lint `map_clone
1 parent 0751259 commit 83f4274

File tree

17 files changed

+40
-81
lines changed

17 files changed

+40
-81
lines changed

stackslib/src/burnchains/burnchain.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl BurnchainStateTransition {
136136
return Some(block_total_burns[0]);
137137
} else if block_total_burns.len() % 2 != 0 {
138138
let idx = block_total_burns.len() / 2;
139-
return block_total_burns.get(idx).map(|b| *b);
139+
return block_total_burns.get(idx).copied();
140140
} else {
141141
// NOTE: the `- 1` is safe because block_total_burns.len() >= 2
142142
let idx_left = block_total_burns.len() / 2 - 1;
@@ -269,8 +269,7 @@ impl BurnchainStateTransition {
269269
let mut missed_commits_at_height =
270270
SortitionDB::get_missed_commits_by_intended(sort_tx.tx(), &sortition_id)?;
271271
if let Some(missed_commit_in_block) = missed_commits_map.remove(&sortition_id) {
272-
missed_commits_at_height
273-
.extend(missed_commit_in_block.into_iter().map(|x| x.clone()));
272+
missed_commits_at_height.extend(missed_commit_in_block.into_iter().cloned());
274273
}
275274

276275
windowed_missed_commits.push(missed_commits_at_height);

stackslib/src/chainstate/stacks/db/unconfirmed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ impl UnconfirmedState {
443443
&self,
444444
txid: &Txid,
445445
) -> Option<(StacksTransaction, BlockHeaderHash, u16)> {
446-
self.mined_txs.get(txid).map(|x| x.clone())
446+
self.mined_txs.get(txid).cloned()
447447
}
448448

449449
pub fn num_microblocks(&self) -> u64 {

stackslib/src/chainstate/stacks/index/cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ impl<T: MarfTrieId> TrieCacheState<T> {
151151

152152
/// Get the block ID, given its hash
153153
pub fn load_block_id(&self, block_hash: &T) -> Option<u32> {
154-
self.block_id_cache.get(block_hash).map(|id| *id)
154+
self.block_id_cache.get(block_hash).copied()
155155
}
156156
}
157157

stackslib/src/clarity_cli.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ pub fn invoke_command(invoked_by: &str, args: &[String]) -> (i32, Option<serde_j
10021002

10031003
match args[0].as_ref() {
10041004
"initialize" => {
1005-
let mut argv: Vec<String> = args.into_iter().map(|x| x.clone()).collect();
1005+
let mut argv: Vec<String> = args.into_iter().cloned().collect();
10061006

10071007
let mainnet = if let Ok(Some(_)) = consume_arg(&mut argv, &["--testnet"], false) {
10081008
false
@@ -1127,7 +1127,7 @@ pub fn invoke_command(invoked_by: &str, args: &[String]) -> (i32, Option<serde_j
11271127
panic_test!();
11281128
}
11291129

1130-
let mut argv: Vec<String> = args.into_iter().map(|x| x.clone()).collect();
1130+
let mut argv: Vec<String> = args.into_iter().cloned().collect();
11311131
let contract_id = if let Ok(optarg) = consume_arg(&mut argv, &["--contract_id"], true) {
11321132
optarg
11331133
.map(|optarg_str| {
@@ -1253,7 +1253,7 @@ pub fn invoke_command(invoked_by: &str, args: &[String]) -> (i32, Option<serde_j
12531253
(0, Some(result))
12541254
}
12551255
"repl" => {
1256-
let mut argv: Vec<String> = args.into_iter().map(|x| x.clone()).collect();
1256+
let mut argv: Vec<String> = args.into_iter().cloned().collect();
12571257
let mainnet = if let Ok(Some(_)) = consume_arg(&mut argv, &["--testnet"], false) {
12581258
false
12591259
} else {
@@ -1385,7 +1385,7 @@ pub fn invoke_command(invoked_by: &str, args: &[String]) -> (i32, Option<serde_j
13851385
}
13861386
}
13871387
"eval" => {
1388-
let mut argv: Vec<String> = args.into_iter().map(|x| x.clone()).collect();
1388+
let mut argv: Vec<String> = args.into_iter().cloned().collect();
13891389

13901390
let costs = if let Ok(Some(_)) = consume_arg(&mut argv, &["--costs"], false) {
13911391
true
@@ -1448,7 +1448,7 @@ pub fn invoke_command(invoked_by: &str, args: &[String]) -> (i32, Option<serde_j
14481448
}
14491449
}
14501450
"eval_at_chaintip" => {
1451-
let mut argv: Vec<String> = args.into_iter().map(|x| x.clone()).collect();
1451+
let mut argv: Vec<String> = args.into_iter().cloned().collect();
14521452

14531453
let costs = if let Ok(Some(_)) = consume_arg(&mut argv, &["--costs"], false) {
14541454
true
@@ -1530,7 +1530,7 @@ pub fn invoke_command(invoked_by: &str, args: &[String]) -> (i32, Option<serde_j
15301530
}
15311531
}
15321532
"eval_at_block" => {
1533-
let mut argv: Vec<String> = args.into_iter().map(|x| x.clone()).collect();
1533+
let mut argv: Vec<String> = args.into_iter().cloned().collect();
15341534

15351535
let costs = if let Ok(Some(_)) = consume_arg(&mut argv, &["--costs"], false) {
15361536
true
@@ -1612,7 +1612,7 @@ pub fn invoke_command(invoked_by: &str, args: &[String]) -> (i32, Option<serde_j
16121612
}
16131613
}
16141614
"launch" => {
1615-
let mut argv: Vec<String> = args.into_iter().map(|x| x.clone()).collect();
1615+
let mut argv: Vec<String> = args.into_iter().cloned().collect();
16161616
let coverage_folder = if let Ok(covarg) = consume_arg(&mut argv, &["--c"], true) {
16171617
covarg
16181618
} else {
@@ -1767,7 +1767,7 @@ pub fn invoke_command(invoked_by: &str, args: &[String]) -> (i32, Option<serde_j
17671767
}
17681768
}
17691769
"execute" => {
1770-
let mut argv: Vec<String> = args.into_iter().map(|x| x.clone()).collect();
1770+
let mut argv: Vec<String> = args.into_iter().cloned().collect();
17711771
let coverage_folder = if let Ok(covarg) = consume_arg(&mut argv, &["--c"], true) {
17721772
covarg
17731773
} else {

stackslib/src/core/mempool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ impl MemPoolWalkTxTypes {
520520
}
521521

522522
pub fn only(selected: &[MemPoolWalkTxTypes]) -> HashSet<MemPoolWalkTxTypes> {
523-
selected.iter().map(|x| x.clone()).collect()
523+
selected.iter().copied().collect()
524524
}
525525
}
526526

stackslib/src/net/api/tests/getheaders.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -295,23 +295,17 @@ fn test_stream_getheaders() {
295295
let block_expected_headers: Vec<StacksBlockHeader> =
296296
blocks.iter().rev().map(|blk| blk.header.clone()).collect();
297297

298-
let block_expected_index_hashes: Vec<StacksBlockId> = blocks_index_hashes
299-
.iter()
300-
.rev()
301-
.map(|idx| idx.clone())
302-
.collect();
298+
let block_expected_index_hashes: Vec<StacksBlockId> =
299+
blocks_index_hashes.iter().rev().copied().collect();
303300

304301
let block_fork_expected_headers: Vec<StacksBlockHeader> = blocks_fork
305302
.iter()
306303
.rev()
307304
.map(|blk| blk.header.clone())
308305
.collect();
309306

310-
let block_fork_expected_index_hashes: Vec<StacksBlockId> = blocks_fork_index_hashes
311-
.iter()
312-
.rev()
313-
.map(|idx| idx.clone())
314-
.collect();
307+
let block_fork_expected_index_hashes: Vec<StacksBlockId> =
308+
blocks_fork_index_hashes.iter().rev().copied().collect();
315309

316310
// get them all -- ask for more than there is
317311
let mut stream =

stackslib/src/net/api/tests/postmempoolquery.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ fn test_try_make_response() {
9696

9797
let test_rpc = TestRPC::setup(function_name!());
9898
let mempool_txids = test_rpc.mempool_txids.clone();
99-
let mempool_txids: HashSet<_> = mempool_txids.iter().map(|txid| txid.clone()).collect();
99+
let mempool_txids: HashSet<_> = mempool_txids.iter().copied().collect();
100100

101101
let sync_data = test_rpc
102102
.peer_1

stackslib/src/net/atlas/download.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ impl AttachmentsBatchStateContext {
373373
}
374374

375375
pub fn get_peers_urls(&self) -> Vec<UrlString> {
376-
self.peers.keys().map(|e| e.clone()).collect()
376+
self.peers.keys().cloned().collect()
377377
}
378378

379379
pub fn get_prioritized_attachments_inventory_requests(
@@ -531,11 +531,7 @@ impl AttachmentsBatchStateContext {
531531
report.bump_failed_requests();
532532
}
533533
}
534-
let mut events_ids = results
535-
.faulty_peers
536-
.keys()
537-
.map(|k| *k)
538-
.collect::<Vec<usize>>();
534+
let mut events_ids = results.faulty_peers.keys().copied().collect::<Vec<usize>>();
539535
self.events_to_deregister.append(&mut events_ids);
540536

541537
self
@@ -565,11 +561,7 @@ impl AttachmentsBatchStateContext {
565561
report.bump_failed_requests();
566562
}
567563
}
568-
let mut events_ids = results
569-
.faulty_peers
570-
.keys()
571-
.map(|k| *k)
572-
.collect::<Vec<usize>>();
564+
let mut events_ids = results.faulty_peers.keys().copied().collect::<Vec<usize>>();
573565
self.events_to_deregister.append(&mut events_ids);
574566

575567
self

stackslib/src/net/db.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,8 +1447,7 @@ impl PeerDB {
14471447
let cur_dbs_set: HashSet<_> = PeerDB::static_get_peer_stacker_dbs(tx, neighbor)?
14481448
.into_iter()
14491449
.collect();
1450-
let new_dbs_set: HashSet<QualifiedContractIdentifier> =
1451-
dbs.iter().map(|cid| cid.clone()).collect();
1450+
let new_dbs_set: HashSet<QualifiedContractIdentifier> = dbs.iter().cloned().collect();
14521451
let to_insert: Vec<_> = new_dbs_set.difference(&cur_dbs_set).collect();
14531452
let to_delete: Vec<_> = cur_dbs_set.difference(&new_dbs_set).collect();
14541453

stackslib/src/net/download/nakamoto/download_state_machine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,7 @@ impl NakamotoDownloadStateMachine {
11441144
) {
11451145
debug!("Run unconfirmed tenure downloaders");
11461146

1147-
let addrs: Vec<_> = downloaders.keys().map(|addr| addr.clone()).collect();
1147+
let addrs: Vec<_> = downloaders.keys().cloned().collect();
11481148
let mut finished = vec![];
11491149
let mut unconfirmed_blocks = HashMap::new();
11501150
let mut highest_completed_tenure_downloaders = HashMap::new();

0 commit comments

Comments
 (0)