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

Method group_bang_eq_op

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

Source from the content-addressed store, hash-verified

121 }
122
123 fn group_bang_eq_op(
124 &self,
125 other: &Box<dyn Value>,
126 group_op: &GroupComparisonOperator,
127 ) -> Result<Box<dyn Value>, String> {
128 if other.is_array_of(|element_type| element_type.is_bool()) {
129 let elements = &other.as_array().unwrap();
130 let mut matches_count = 0;
131 for element in elements.iter() {
132 if self.value != element.as_bool().unwrap() {
133 matches_count += 1;
134 if GroupComparisonOperator::Any.eq(group_op) {
135 break;
136 }
137 }
138 }
139
140 let result = match group_op {
141 GroupComparisonOperator::All => matches_count == elements.len(),
142 GroupComparisonOperator::Any => matches_count > 0,
143 };
144
145 return Ok(Box::new(BoolValue::new(result)));
146 }
147 Err("Unexpected type to perform `!=` with".to_string())
148 }
149
150 fn gt_op(&self, other: &Box<dyn Value>) -> Result<Box<dyn Value>, String> {
151 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