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

Method group_eq_op

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

Source from the content-addressed store, hash-verified

67 }
68
69 fn group_eq_op(
70 &self,
71 other: &Box<dyn Value>,
72 group_op: &GroupComparisonOperator,
73 ) -> Result<Box<dyn Value>, String> {
74 if other.is_array_of(|element_type| element_type.is_text()) {
75 let elements = &other.as_array().unwrap();
76 let mut matches_count = 0;
77 for element in elements.iter() {
78 if self.value == element.as_text().unwrap() {
79 matches_count += 1;
80 if GroupComparisonOperator::Any.eq(group_op) {
81 break;
82 }
83 }
84 }
85
86 let result = match group_op {
87 GroupComparisonOperator::All => matches_count == elements.len(),
88 GroupComparisonOperator::Any => matches_count > 0,
89 };
90
91 return Ok(Box::new(BoolValue::new(result)));
92 }
93 Err("Unexpected type to perform `=` with".to_string())
94 }
95
96 fn bang_eq_op(&self, other: &Box<dyn Value>) -> Result<Box<dyn Value>, String> {
97 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