Skip to content

Commit d2b998b

Browse files
committed
clippy: fix explicit-iter-loop and explicit-into-iter-loop lints
1 parent ad2eaac commit d2b998b

13 files changed

Lines changed: 28 additions & 28 deletions

File tree

src/address.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ impl FromStr for Address {
692692
let net_arr = [liq, ele, liq_test];
693693

694694
let prefix = find_prefix(s);
695-
for net in net_arr.iter() {
695+
for net in &net_arr {
696696
// Bech32.
697697
if match_prefix(prefix, net.bech_hrp) {
698698
return Address::from_bech32(s, false, net);
@@ -712,7 +712,7 @@ impl FromStr for Address {
712712
}
713713

714714
let p = data[0];
715-
for net in net_arr.iter() {
715+
for net in &net_arr {
716716
if p == net.p2pkh_prefix || p == net.p2sh_prefix || p == net.blinded_prefix {
717717
return Address::from_base58(&data, net);
718718
}

src/blind.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ impl Transaction {
10021002
(inp.asset_issuance.amount, asset_id),
10031003
(inp.asset_issuance.inflation_keys, token_id),
10041004
];
1005-
for (amt, asset) in arr.iter() {
1005+
for (amt, asset) in &arr {
10061006
match amt {
10071007
Value::Null => continue,
10081008
Value::Explicit(v) => {

src/confidential.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ impl fmt::Display for Nonce {
598598
match *self {
599599
Nonce::Null => f.write_str("null"),
600600
Nonce::Explicit(n) => {
601-
for b in n.iter() {
601+
for b in &n {
602602
write!(f, "{:02x}", b)?;
603603
}
604604
Ok(())

src/pset/map/global.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,14 @@ impl Map for Global {
276276
rv.push_prop(self.elements_tx_modifiable_flag as <PSBT_ELEMENTS_GLOBAL_TX_MODIFIABLE, _>)
277277
}
278278

279-
for (key, value) in self.proprietary.iter() {
279+
for (key, value) in &self.proprietary {
280280
rv.push(raw::Pair {
281281
key: key.to_key(),
282282
value: value.clone(),
283283
});
284284
}
285285

286-
for (key, value) in self.unknown.iter() {
286+
for (key, value) in &self.unknown {
287287
rv.push(raw::Pair {
288288
key: key.clone(),
289289
value: value.clone(),

src/pset/map/input.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,14 +1029,14 @@ impl Map for Input {
10291029
rv.push_prop(self.blinded_issuance as <PSBT_ELEMENTS_IN_BLINDED_ISSUANCE, _>)
10301030
}
10311031

1032-
for (key, value) in self.proprietary.iter() {
1032+
for (key, value) in &self.proprietary {
10331033
rv.push(raw::Pair {
10341034
key: key.to_key(),
10351035
value: value.clone(),
10361036
});
10371037
}
10381038

1039-
for (key, value) in self.unknown.iter() {
1039+
for (key, value) in &self.unknown {
10401040
rv.push(raw::Pair {
10411041
key: key.clone(),
10421042
value: value.clone(),

src/pset/map/output.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,14 +488,14 @@ impl Map for Output {
488488
rv.push_prop(self.blind_asset_proof as <PSBT_ELEMENTS_OUT_BLIND_ASSET_PROOF, _>)
489489
}
490490

491-
for (key, value) in self.proprietary.iter() {
491+
for (key, value) in &self.proprietary {
492492
rv.push(raw::Pair {
493493
key: key.to_key(),
494494
value: value.clone(),
495495
});
496496
}
497497

498-
for (key, value) in self.unknown.iter() {
498+
for (key, value) in &self.unknown {
499499
rv.push(raw::Pair {
500500
key: key.clone(),
501501
value: value.clone(),

src/pset/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ impl PartiallySignedTransaction {
257257
// changed by Updaters and Combiners, the sequence number in this unsigned
258258
// transaction must be set to 0 (not final, nor the sequence in PSBT_IN_SEQUENCE).
259259
// The lock time in this unsigned transaction must be computed as described previously.
260-
for inp in tx.input.iter_mut() {
260+
for inp in &mut tx.input {
261261
inp.sequence = Sequence::from_height(0);
262262
}
263263
Ok(tx.txid())
@@ -283,7 +283,7 @@ impl PartiallySignedTransaction {
283283
let mut inputs = vec![];
284284
let mut outputs = vec![];
285285

286-
for psetin in self.inputs.iter() {
286+
for psetin in &self.inputs {
287287
let txin = TxIn {
288288
previous_output: OutPoint::new(psetin.previous_txid, psetin.previous_output_index),
289289
is_pegin: psetin.is_pegin(),
@@ -308,7 +308,7 @@ impl PartiallySignedTransaction {
308308
inputs.push(txin);
309309
}
310310

311-
for out in self.outputs.iter() {
311+
for out in &self.outputs {
312312
let txout = TxOut {
313313
asset: match (out.asset_comm, out.asset) {
314314
(Some(gen), _) => confidential::Asset::Confidential(gen),
@@ -634,7 +634,7 @@ impl PartiallySignedTransaction {
634634
ValueBlindingFactor::last(secp, value, out_abf, &inp_secrets, &exp_out_secrets);
635635

636636
// Add all the scalars
637-
for value_diff in self.global.scalars.iter() {
637+
for value_diff in &self.global.scalars {
638638
final_vbf += ValueBlindingFactor(*value_diff);
639639
}
640640

src/pset/serialize.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ impl Serialize for KeySource {
166166

167167
rv.append(&mut self.0.to_bytes().to_vec());
168168

169-
for cnum in self.1.into_iter() {
169+
for cnum in &self.1 {
170170
rv.append(&mut serialize(&u32::from(*cnum)))
171171
}
172172

@@ -438,7 +438,7 @@ impl Serialize for TapTree {
438438
match (self.0.branch().len(), self.0.branch().last()) {
439439
(1, Some(Some(root))) => {
440440
let mut buf = Vec::new();
441-
for leaf_info in root.leaves.iter() {
441+
for leaf_info in &root.leaves {
442442
// # Cast Safety:
443443
//
444444
// TaprootMerkleBranch can only have len atmost 128(TAPROOT_CONTROL_MAX_NODE_COUNT).

src/script.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,8 +1080,8 @@ mod test {
10801080
assert_eq!(build_scriptint(256), vec![0, 1]);
10811081
assert_eq!(build_scriptint(257), vec![1, 1]);
10821082
assert_eq!(build_scriptint(511), vec![255, 1]);
1083-
for &i in [10, 100, 255, 256, 1000, 10000, 25000, 200000, 5000000, 1000000000,
1084-
(1 << 31) - 1, -((1 << 31) - 1)].iter() {
1083+
for &i in &[10, 100, 255, 256, 1000, 10000, 25000, 200000, 5000000, 1000000000,
1084+
(1 << 31) - 1, -((1 << 31) - 1)] {
10851085
assert_eq!(Ok(i), read_scriptint(&build_scriptint(i)));
10861086
assert_eq!(Ok(-i), read_scriptint(&build_scriptint(-i)));
10871087
}

src/serde_utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub mod btreemap_byte_values {
2222
serde::Serialize::serialize(v, s)
2323
} else {
2424
let mut map = s.serialize_map(Some(v.len()))?;
25-
for (key, value) in v.iter() {
25+
for (key, value) in v {
2626
map.serialize_entry(key, &value.to_hex())?;
2727
}
2828
map.end()
@@ -89,7 +89,7 @@ pub mod btreemap_as_seq {
8989
serde::Serialize::serialize(v, s)
9090
} else {
9191
let mut seq = s.serialize_seq(Some(v.len()))?;
92-
for pair in v.iter() {
92+
for pair in v {
9393
seq.serialize_element(&pair)?;
9494
}
9595
seq.end()
@@ -175,7 +175,7 @@ pub mod btreemap_as_seq_byte_values {
175175
serde::Serialize::serialize(v, s)
176176
} else {
177177
let mut seq = s.serialize_seq(Some(v.len()))?;
178-
for (key, value) in v.iter() {
178+
for (key, value) in v {
179179
seq.serialize_element(&BorrowedPair(key, value))?;
180180
}
181181
seq.end()

0 commit comments

Comments
 (0)