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

Method group_lte_op

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

Source from the content-addressed store, hash-verified

329 }
330
331 fn group_lte_op(
332 &self,
333 other: &Box<dyn Value>,
334 group_op: &GroupComparisonOperator,
335 ) -> Result<Box<dyn Value>, String> {
336 if other.is_array_of(|element_type| element_type.is_int()) {
337 let elements = &other.as_array().unwrap();
338 let mut matches_count = 0;
339 for element in elements.iter() {
340 if self.value <= element.as_int().unwrap() {
341 matches_count += 1;
342 if GroupComparisonOperator::Any.eq(group_op) {
343 break;
344 }
345 }
346 }
347
348 let result = match group_op {
349 GroupComparisonOperator::All => matches_count == elements.len(),
350 GroupComparisonOperator::Any => matches_count > 0,
351 };
352
353 return Ok(Box::new(BoolValue::new(result)));
354 }
355 Err("Unexpected type to perform `<=` with".to_string())
356 }
357
358 fn plus_op(&self) -> Result<Box<dyn Value>, String> {
359 Ok(Box::new(IntValue::new(self.value)))

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