mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-04 15:07:47 +00:00
refactor/polish ~ fix cargo clippy
complaints (allow comparison_chain {for f64 comparisons})
This commit is contained in:
parent
784887cc84
commit
5241eca084
1 changed files with 3 additions and 0 deletions
|
@ -398,6 +398,7 @@ fn default_compare(a: &str, b: &str) -> Ordering {
|
||||||
/// Stops coercing at the first whitespace char, so 1e2 will parse as 100 but
|
/// Stops coercing at the first whitespace char, so 1e2 will parse as 100 but
|
||||||
/// 1,000 will parse as -inf.
|
/// 1,000 will parse as -inf.
|
||||||
fn numeric_compare(a: &str, b: &str) -> Ordering {
|
fn numeric_compare(a: &str, b: &str) -> Ordering {
|
||||||
|
#![allow(clippy::comparison_chain)]
|
||||||
let fa = permissive_f64_parse(a);
|
let fa = permissive_f64_parse(a);
|
||||||
let fb = permissive_f64_parse(b);
|
let fb = permissive_f64_parse(b);
|
||||||
// f64::cmp isn't implemented because NaN messes with it
|
// f64::cmp isn't implemented because NaN messes with it
|
||||||
|
@ -434,8 +435,10 @@ fn human_numeric_convert(a: &str) -> f64 {
|
||||||
/// Compare two strings as if they are human readable sizes.
|
/// Compare two strings as if they are human readable sizes.
|
||||||
/// AKA 1M > 100k
|
/// AKA 1M > 100k
|
||||||
fn human_numeric_size_compare(a: &str, b: &str) -> Ordering {
|
fn human_numeric_size_compare(a: &str, b: &str) -> Ordering {
|
||||||
|
#![allow(clippy::comparison_chain)]
|
||||||
let fa = human_numeric_convert(a);
|
let fa = human_numeric_convert(a);
|
||||||
let fb = human_numeric_convert(b);
|
let fb = human_numeric_convert(b);
|
||||||
|
// f64::cmp isn't implemented (due to NaN issues); implement directly instead
|
||||||
if fa > fb {
|
if fa > fb {
|
||||||
Ordering::Greater
|
Ordering::Greater
|
||||||
} else if fa < fb {
|
} else if fa < fb {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue