Coerce a result cell to `f64`, accepting either a native numeric value or a text-encoded number (the pgwire transport renders floats as text).
(v: &Value)
| 83 | /// Coerce a result cell to `f64`, accepting either a native numeric value or a |
| 84 | /// text-encoded number (the pgwire transport renders floats as text). |
| 85 | fn value_as_f64(v: &Value) -> Option<f64> { |
| 86 | v.as_f64() |
| 87 | .or_else(|| v.as_str().and_then(|s| s.parse().ok())) |
| 88 | } |
| 89 | |
| 90 | #[cfg(test)] |
| 91 | mod tests { |