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

Method group_bang_eq_op

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

Source from the content-addressed store, hash-verified

101 }
102
103 fn group_bang_eq_op(
104 &self,
105 other: &Box<dyn Value>,
106 group_op: &GroupComparisonOperator,
107 ) -> Result<Box<dyn Value>, String> {
108 if other.is_array_of(|element_type| element_type.is_text()) {
109 let elements = &other.as_array().unwrap();
110 let mut matches_count = 0;
111 for element in elements.iter() {
112 if self.value != element.as_text().unwrap() {
113 matches_count += 1;
114 if GroupComparisonOperator::Any.eq(group_op) {
115 break;
116 }
117 }
118 }
119
120 let result = match group_op {
121 GroupComparisonOperator::All => matches_count == elements.len(),
122 GroupComparisonOperator::Any => matches_count > 0,
123 };
124
125 return Ok(Box::new(BoolValue::new(result)));
126 }
127 Err("Unexpected type to perform `!=` with".to_string())
128 }
129
130 fn gt_op(&self, other: &Box<dyn Value>) -> Result<Box<dyn Value>, String> {
131 if let Some(other_text) = other.as_any().downcast_ref::<TextValue>() {

Callers

nothing calls this directly

Calls 6

is_array_ofMethod · 0.80
as_arrayMethod · 0.80
as_textMethod · 0.80
is_textMethod · 0.45
eqMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected