Skip to content

Commit f2f7b8c

Browse files
authored
Revert "fix(forge): use float total cmp instead partial (foundry-rs#10005) (#17)"
This reverts commit 1e98af9.
1 parent 923914e commit f2f7b8c

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

crates/cli/src/utils/suggestions.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! Helper functions for suggesting alternative values for a possibly erroneous user input.
2+
use std::cmp::Ordering;
23

34
/// Filters multiple strings from a given list of possible values which are similar
45
/// to the passed in value `v` within a certain confidence by least confidence.
@@ -16,7 +17,7 @@ where
1617
.map(|pv| (strsim::jaro_winkler(v, pv.as_ref()), pv.as_ref().to_owned()))
1718
.filter(|(similarity, _)| *similarity > 0.8)
1819
.collect();
19-
candidates.sort_by(|a, b| a.0.total_cmp(&b.0));
20+
candidates.sort_by(|a, b| a.0.partial_cmp(&b.0).unwrap_or(Ordering::Equal));
2021
candidates.into_iter().map(|(_, pv)| pv).collect()
2122
}
2223

crates/common/src/contracts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ impl ContractsByArtifact {
147147
None
148148
}
149149
})
150-
.min_by(|(score1, _), (score2, _)| score1.total_cmp(score2))
150+
.min_by(|(score1, _), (score2, _)| score1.partial_cmp(score2).unwrap())
151151
.map(|(_, data)| data)
152152
}
153153

crates/forge/bin/cmd/snapshot.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,9 @@ fn diff(tests: Vec<SuiteTestResult>, snaps: Vec<GasSnapshotEntry>) -> Result<()>
373373
let mut overall_gas_change = 0i128;
374374
let mut overall_gas_used = 0i128;
375375

376-
diffs.sort_by(|a, b| a.gas_diff().abs().total_cmp(&b.gas_diff().abs()));
376+
diffs.sort_by(|a, b| {
377+
a.gas_diff().abs().partial_cmp(&b.gas_diff().abs()).unwrap_or(Ordering::Equal)
378+
});
377379

378380
for diff in diffs {
379381
let gas_change = diff.gas_change();
@@ -399,7 +401,7 @@ fn diff(tests: Vec<SuiteTestResult>, snaps: Vec<GasSnapshotEntry>) -> Result<()>
399401

400402
fn fmt_pct_change(change: f64) -> String {
401403
let change_pct = change * 100.0;
402-
match change.total_cmp(&0.0) {
404+
match change.partial_cmp(&0.0).unwrap_or(Ordering::Equal) {
403405
Ordering::Less => format!("{change_pct:.3}%").green().to_string(),
404406
Ordering::Equal => {
405407
format!("{change_pct:.3}%")

0 commit comments

Comments
 (0)