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

Method cast_to_boolean

graphlite/src/exec/executor.rs:4995–5013  ·  view source on GitHub ↗

Cast value to BOOLEAN

(&self, value: Value)

Source from the content-addressed store, hash-verified

4993
4994 /// Cast value to BOOLEAN
4995 fn cast_to_boolean(&self, value: Value) -> Result<Value, ExecutionError> {
4996 match value {
4997 Value::Boolean(b) => Ok(Value::Boolean(b)),
4998 Value::Number(n) => Ok(Value::Boolean(n != 0.0)),
4999 Value::String(s) => match s.to_lowercase().as_str() {
5000 "true" | "1" | "yes" | "on" => Ok(Value::Boolean(true)),
5001 "false" | "0" | "no" | "off" | "" => Ok(Value::Boolean(false)),
5002 _ => Err(ExecutionError::RuntimeError(format!(
5003 "Cannot cast '{}' to BOOLEAN",
5004 s
5005 ))),
5006 },
5007 Value::Null => Ok(Value::Null),
5008 _ => Err(ExecutionError::RuntimeError(format!(
5009 "Cannot cast {:?} to BOOLEAN",
5010 value.type_name()
5011 ))),
5012 }
5013 }
5014
5015 /// Cast value to STRING
5016 fn cast_to_string(

Callers 1

cast_valueMethod · 0.80

Calls 1

as_strMethod · 0.45

Tested by

no test coverage detected