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

Method caret_op

crates/gitql-core/src/values/integer.rs:97–106  ·  view source on GitHub ↗
(&self, other: &Box<dyn Value>)

Source from the content-addressed store, hash-verified

95 }
96
97 fn caret_op(&self, other: &Box<dyn Value>) -> Result<Box<dyn Value>, String> {
98 if let Some(other_int) = other.as_any().downcast_ref::<IntValue>() {
99 if other_int.value < 0 {
100 return Err("Caret right side hand can't be negative value".to_string());
101 }
102 let value = self.value.pow(other_int.value as u32);
103 return Ok(Box::new(IntValue::new(value)));
104 }
105 Err("Unexpected type to perform `^` with".to_string())
106 }
107
108 fn or_op(&self, other: &Box<dyn Value>) -> Result<Box<dyn Value>, String> {
109 if let Some(other_int) = other.as_any().downcast_ref::<IntValue>() {

Callers 1

evaluate_arithmeticFunction · 0.45

Calls 1

as_anyMethod · 0.45

Tested by

no test coverage detected