MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / cast_to_double

Method cast_to_double

graphlite/src/exec/executor.rs:5116–5133  ·  view source on GitHub ↗

Cast value to DOUBLE

(&self, value: Value)

Source from the content-addressed store, hash-verified

5114
5115 /// Cast value to DOUBLE
5116 fn cast_to_double(&self, value: Value) -> Result<Value, ExecutionError> {
5117 match value {
5118 Value::Number(n) => Ok(Value::Number(n)),
5119 Value::String(s) => match s.parse::<f64>() {
5120 Ok(n) => Ok(Value::Number(n)),
5121 Err(_) => Err(ExecutionError::RuntimeError(format!(
5122 "Cannot cast '{}' to DOUBLE",
5123 s
5124 ))),
5125 },
5126 Value::Boolean(b) => Ok(Value::Number(if b { 1.0 } else { 0.0 })),
5127 Value::Null => Ok(Value::Null),
5128 _ => Err(ExecutionError::RuntimeError(format!(
5129 "Cannot cast {:?} to DOUBLE",
5130 value.type_name()
5131 ))),
5132 }
5133 }
5134
5135 /// Cast value to DECIMAL
5136 fn cast_to_decimal(

Callers 4

cast_valueMethod · 0.80
cast_to_floatMethod · 0.80
cast_to_realMethod · 0.80
cast_to_decimalMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected