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)
| 48 | /// Handles `"5" == 5` by coercing both sides to f64 when one is a |
| 49 | /// number and the other is a numeric string. |
| 50 | pub 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 | /// |
nothing calls this directly
no test coverage detected