MCPcopy Create free account
hub / github.com/AmrDeveloper/GQL / cast_op

Method cast_op

crates/gitql-core/src/values/integer.rs:366–380  ·  view source on GitHub ↗
(&self, target_type: &Box<dyn DataType>)

Source from the content-addressed store, hash-verified

364 }
365
366 fn cast_op(&self, target_type: &Box<dyn DataType>) -> Result<Box<dyn Value>, String> {
367 // Cast to Boolean
368 if target_type.is_bool() {
369 let value = self.value != 0;
370 return Ok(Box::new(BoolValue::new(value)));
371 }
372
373 // Cast to Float
374 if target_type.is_float() {
375 let value = self.value as f64;
376 return Ok(Box::new(FloatValue { value }));
377 }
378
379 Err("Unexpected value to perform `CAST` with".to_string())
380 }
381}

Callers

nothing calls this directly

Calls 2

is_boolMethod · 0.45
is_floatMethod · 0.45

Tested by

no test coverage detected