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

Method group_eq_op

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

Source from the content-addressed store, hash-verified

154 }
155
156 fn group_eq_op(
157 &self,
158 other: &Box<dyn Value>,
159 group_op: &GroupComparisonOperator,
160 ) -> Result<Box<dyn Value>, String> {
161 if other.is_array_of(|element_type| element_type.is_int()) {
162 let elements = &other.as_array().unwrap();
163 let mut matches_count = 0;
164 for element in elements.iter() {
165 if self.value == element.as_int().unwrap() {
166 matches_count += 1;
167 if GroupComparisonOperator::Any.eq(group_op) {
168 break;
169 }
170 }
171 }
172
173 let result = match group_op {
174 GroupComparisonOperator::All => matches_count == elements.len(),
175 GroupComparisonOperator::Any => matches_count > 0,
176 };
177
178 return Ok(Box::new(BoolValue::new(result)));
179 }
180 Err("Unexpected type to perform `=` with".to_string())
181 }
182
183 fn bang_eq_op(&self, other: &Box<dyn Value>) -> Result<Box<dyn Value>, String> {
184 if let Some(other_bool) = other.as_any().downcast_ref::<IntValue>() {

Callers

nothing calls this directly

Calls 6

is_array_ofMethod · 0.80
as_arrayMethod · 0.80
as_intMethod · 0.80
is_intMethod · 0.45
eqMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected