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

Method index_op

crates/gitql-core/src/values/array.rs:89–99  ·  view source on GitHub ↗
(&self, index: &Box<dyn Value>)

Source from the content-addressed store, hash-verified

87 }
88
89 fn index_op(&self, index: &Box<dyn Value>) -> Result<Box<dyn Value>, String> {
90 if let Some(index) = index.as_any().downcast_ref::<IntValue>() {
91 if (index.value < 1) || (index.value as usize > self.values.len()) {
92 return Err("Array Index must be between 1 and length of Array".to_string());
93 }
94
95 let array_index = (index.value - 1) as usize;
96 return Ok(self.values[array_index].clone());
97 }
98 Err("Unexpected Array Index type".to_string())
99 }
100
101 fn slice_op(
102 &self,

Callers 1

Calls 2

as_anyMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected