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

Function coerced_eq

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

Check equality with type coercion. Handles `"5" == 5` by coercing both sides to f64 when one is a number and the other is a numeric string.

(a: &Value, b: &Value)

Source from the content-addressed store, hash-verified

48/// Handles `"5" == 5` by coercing both sides to f64 when one is a
49/// number and the other is a numeric string.
50pub fn coerced_eq(a: &Value, b: &Value) -> bool {
51 if a == b {
52 return true;
53 }
54 if let (Some(af), Some(bf)) = (value_to_f64(a, true), value_to_f64(b, true)) {
55 return (af - bf).abs() < f64::EPSILON;
56 }
57 false
58}
59
60/// Check if a Value is truthy (for boolean contexts).
61///

Callers

nothing calls this directly

Calls 1

value_to_f64Function · 0.85

Tested by

no test coverage detected