MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / compare_values

Function compare_values

nodedb-query/src/value_ops.rs:37–44  ·  view source on GitHub ↗

Compare two Values with type coercion. Tries numeric comparison first (with bool coercion), then falls back to string comparison.

(a: &Value, b: &Value)

Source from the content-addressed store, hash-verified

35/// Tries numeric comparison first (with bool coercion), then falls
36/// back to string comparison.
37pub fn compare_values(a: &Value, b: &Value) -> Ordering {
38 if let (Some(na), Some(nb)) = (value_to_f64(a, true), value_to_f64(b, true)) {
39 return na.partial_cmp(&nb).unwrap_or(Ordering::Equal);
40 }
41 let sa = value_to_display_string(a);
42 let sb = value_to_display_string(b);
43 sa.cmp(&sb)
44}
45
46/// Check equality with type coercion.
47///

Callers 4

eval_binary_opFunction · 0.50
cmp_valuesFunction · 0.50
try_evalFunction · 0.50
find_minmaxFunction · 0.50

Calls 4

value_to_f64Function · 0.85
value_to_display_stringFunction · 0.85
partial_cmpMethod · 0.45
cmpMethod · 0.45

Tested by

no test coverage detected