Skip to content

Commit fa56822

Browse files
fix(clippy): use sort_unstable_by_key instead of sort_unstable_by (#122)
fix: use sort_unstable_by_key instead of sort_unstable_by Amp-Thread-ID: https://ampcode.com/threads/T-019bf224-31e6-71d9-b81d-b8822bdc0348 Co-authored-by: Amp <amp@ampcode.com>
1 parent 7f127a5 commit fa56822

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/proof/decoded_proof_nodes.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl DecodedProofNodes {
6060
/// Return the sorted vec of proof nodes that match the target.
6161
pub fn matching_nodes_sorted(&self, target: &Nibbles) -> Vec<(Nibbles, TrieNode)> {
6262
let mut nodes = self.matching_nodes(target);
63-
nodes.sort_unstable_by(|a, b| a.0.cmp(&b.0));
63+
nodes.sort_unstable_by_key(|a| a.0);
6464
nodes
6565
}
6666

@@ -81,14 +81,14 @@ impl DecodedProofNodes {
8181
/// Return the sorted vec of all proof nodes.
8282
pub fn nodes_sorted(&self) -> Vec<(Nibbles, TrieNode)> {
8383
let mut nodes = Vec::from_iter(self.0.iter().map(|(k, v)| (*k, v.clone())));
84-
nodes.sort_unstable_by(|a, b| a.0.cmp(&b.0));
84+
nodes.sort_unstable_by_key(|a| a.0);
8585
nodes
8686
}
8787

8888
/// Convert into sorted vec of all proof nodes.
8989
pub fn into_nodes_sorted(self) -> Vec<(Nibbles, TrieNode)> {
9090
let mut nodes = Vec::from_iter(self.0);
91-
nodes.sort_unstable_by(|a, b| a.0.cmp(&b.0));
91+
nodes.sort_unstable_by_key(|a| a.0);
9292
nodes
9393
}
9494

src/proof/proof_nodes.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl ProofNodes {
4646
/// Return the sorted vec of proof nodes that match the target.
4747
pub fn matching_nodes_sorted(&self, target: &Nibbles) -> Vec<(Nibbles, Bytes)> {
4848
let mut nodes = self.matching_nodes(target);
49-
nodes.sort_unstable_by(|a, b| a.0.cmp(&b.0));
49+
nodes.sort_unstable_by_key(|a| a.0);
5050
nodes
5151
}
5252

@@ -58,14 +58,14 @@ impl ProofNodes {
5858
/// Return the sorted vec of all proof nodes.
5959
pub fn nodes_sorted(&self) -> Vec<(Nibbles, Bytes)> {
6060
let mut nodes = Vec::from_iter(self.0.iter().map(|(k, v)| (*k, v.clone())));
61-
nodes.sort_unstable_by(|a, b| a.0.cmp(&b.0));
61+
nodes.sort_unstable_by_key(|a| a.0);
6262
nodes
6363
}
6464

6565
/// Convert into sorted vec of all proof nodes.
6666
pub fn into_nodes_sorted(self) -> Vec<(Nibbles, Bytes)> {
6767
let mut nodes = Vec::from_iter(self.0);
68-
nodes.sort_unstable_by(|a, b| a.0.cmp(&b.0));
68+
nodes.sort_unstable_by_key(|a| a.0);
6969
nodes
7070
}
7171

0 commit comments

Comments
 (0)