Performs a type conversion on the target.
(ftx: &FunctionContext, This(this): This<Value>)
| 161 | |
| 162 | // Performs a type conversion on the target. |
| 163 | pub fn double(ftx: &FunctionContext, This(this): This<Value>) -> Result<Value> { |
| 164 | Ok(match this { |
| 165 | Value::String(v) => v |
| 166 | .parse::<f64>() |
| 167 | .map(Value::Float) |
| 168 | .map_err(|e| ftx.error(format!("string parse error: {e}")))?, |
| 169 | Value::Float(v) => Value::Float(v), |
| 170 | Value::Int(v) => Value::Float(v as f64), |
| 171 | Value::UInt(v) => Value::Float(v as f64), |
| 172 | v => return Err(ftx.error(format!("cannot convert {v:?} to double"))), |
| 173 | }) |
| 174 | } |
| 175 | |
| 176 | // Performs a type conversion on the target. |
| 177 | pub fn uint(ftx: &FunctionContext, This(this): This<Value>) -> Result<Value> { |
no test coverage detected