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

Method group_eq_op

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

Source from the content-addressed store, hash-verified

87 }
88
89 fn group_eq_op(
90 &self,
91 other: &Box<dyn Value>,
92 group_op: &GroupComparisonOperator,
93 ) -> Result<Box<dyn Value>, String> {
94 if other.is_array_of(|element_type| element_type.is_bool()) {
95 let elements = &other.as_array().unwrap();
96 let mut matches_count = 0;
97 for element in elements.iter() {
98 if self.value == element.as_bool().unwrap() {
99 matches_count += 1;
100 if GroupComparisonOperator::Any.eq(group_op) {
101 break;
102 }
103 }
104 }
105
106 let result = match group_op {
107 GroupComparisonOperator::All => matches_count == elements.len(),
108 GroupComparisonOperator::Any => matches_count > 0,
109 };
110
111 return Ok(Box::new(BoolValue::new(result)));
112 }
113 Err("Unexpected type to perform `=` with".to_string())
114 }
115
116 fn bang_eq_op(&self, other: &Box<dyn Value>) -> Result<Box<dyn Value>, String> {
117 if let Some(other_bool) = other.as_any().downcast_ref::<BoolValue>() {

Callers

nothing calls this directly

Calls 6

is_array_ofMethod · 0.80
as_arrayMethod · 0.80
as_boolMethod · 0.80
is_boolMethod · 0.45
eqMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected