cleanup(rust): Simplify code using closure capture in Rust 2021 edition (#6737)
* Simplify code using closure capture in Rust 2021 edition * clippy: manual_next_back and unit_arg * cargo fmt --all
This commit is contained in:
parent
f6641eaaee
commit
3f13072c46
|
@ -866,8 +866,7 @@ async fn v5_transaction_is_rejected_before_nu5_activation() {
|
|||
let verifier = Verifier::new(network, state_service);
|
||||
|
||||
let transaction = fake_v5_transactions_for_network(network, blocks)
|
||||
.rev()
|
||||
.next()
|
||||
.next_back()
|
||||
.expect("At least one fake V5 transaction in the test vectors");
|
||||
|
||||
let result = verifier
|
||||
|
@ -918,8 +917,7 @@ fn v5_transaction_is_accepted_after_nu5_activation_for_network(network: Network)
|
|||
let verifier = Verifier::new(network, state_service);
|
||||
|
||||
let mut transaction = fake_v5_transactions_for_network(network, blocks)
|
||||
.rev()
|
||||
.next()
|
||||
.next_back()
|
||||
.expect("At least one fake V5 transaction in the test vectors");
|
||||
if transaction
|
||||
.expiry_height()
|
||||
|
|
|
@ -504,15 +504,12 @@ where
|
|||
/// Checks if the minimum peer version has changed, and disconnects from outdated peers.
|
||||
fn disconnect_from_outdated_peers(&mut self) {
|
||||
if let Some(minimum_version) = self.minimum_peer_version.changed() {
|
||||
// TODO: Remove when the code base migrates to Rust 2021 edition (#2709).
|
||||
let preselected_p2c_peer = &mut self.preselected_p2c_peer;
|
||||
|
||||
self.ready_services.retain(|address, peer| {
|
||||
if peer.remote_version() >= minimum_version {
|
||||
true
|
||||
} else {
|
||||
if *preselected_p2c_peer == Some(*address) {
|
||||
*preselected_p2c_peer = None;
|
||||
if self.preselected_p2c_peer == Some(*address) {
|
||||
self.preselected_p2c_peer = None;
|
||||
}
|
||||
|
||||
false
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
//! Fixed test vectors for the RPC server.
|
||||
|
||||
// These tests call functions which can take unit arguments if some features aren't enabled.
|
||||
#![allow(clippy::unit_arg)]
|
||||
|
||||
use std::{
|
||||
net::{Ipv4Addr, SocketAddrV4},
|
||||
time::Duration,
|
||||
|
|
|
@ -549,7 +549,7 @@ impl NonFinalizedState {
|
|||
|
||||
/// Return the non-finalized portion of the current best chain.
|
||||
pub fn best_chain(&self) -> Option<&Arc<Chain>> {
|
||||
self.chain_set.iter().rev().next()
|
||||
self.chain_iter().next()
|
||||
}
|
||||
|
||||
/// Return the number of chains.
|
||||
|
|
Loading…
Reference in New Issue