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

Method group_eq_op

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

Source from the content-addressed store, hash-verified

78 }
79
80 fn group_eq_op(
81 &self,
82 other: &Box<dyn Value>,
83 group_op: &GroupComparisonOperator,
84 ) -> Result<Box<dyn Value>, String> {
85 if other.is_array_of(|element_type| element_type.is_date()) {
86 let elements = &other.as_array().unwrap();
87 let mut matches_count = 0;
88 for element in elements.iter() {
89 if self.timestamp == element.as_date().unwrap() {
90 matches_count += 1;
91 if GroupComparisonOperator::Any.eq(group_op) {
92 break;
93 }
94 }
95 }
96
97 let result = match group_op {
98 GroupComparisonOperator::All => matches_count == elements.len(),
99 GroupComparisonOperator::Any => matches_count > 0,
100 };
101
102 return Ok(Box::new(BoolValue::new(result)));
103 }
104 Err("Unexpected type to perform `=` with".to_string())
105 }
106
107 fn bang_eq_op(&self, other: &Box<dyn Value>) -> Result<Box<dyn Value>, String> {
108 if let Some(other_text) = other.as_any().downcast_ref::<DateValue>() {

Callers 1

Calls 6

is_array_ofMethod · 0.80
as_arrayMethod · 0.80
as_dateMethod · 0.80
is_dateMethod · 0.45
eqMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected