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

Method group_bang_eq_op

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

Source from the content-addressed store, hash-verified

189 }
190
191 fn group_bang_eq_op(
192 &self,
193 other: &Box<dyn Value>,
194 group_op: &GroupComparisonOperator,
195 ) -> Result<Box<dyn Value>, String> {
196 if other.is_array_of(|element_type| element_type.is_int()) {
197 let elements = &other.as_array().unwrap();
198 let mut matches_count = 0;
199 for element in elements.iter() {
200 if self.value != element.as_int().unwrap() {
201 matches_count += 1;
202 if GroupComparisonOperator::Any.eq(group_op) {
203 break;
204 }
205 }
206 }
207
208 let result = match group_op {
209 GroupComparisonOperator::All => matches_count == elements.len(),
210 GroupComparisonOperator::Any => matches_count > 0,
211 };
212
213 return Ok(Box::new(BoolValue::new(result)));
214 }
215 Err("Unexpected type to perform `!=` with".to_string())
216 }
217
218 fn gt_op(&self, other: &Box<dyn Value>) -> Result<Box<dyn Value>, String> {
219 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