| 169 | } |
| 170 | |
| 171 | fn group_gte_op( |
| 172 | &self, |
| 173 | other: &Box<dyn Value>, |
| 174 | group_op: &GroupComparisonOperator, |
| 175 | ) -> Result<Box<dyn Value>, String> { |
| 176 | if other.is_array_of(|element_type| element_type.is_text()) { |
| 177 | let elements = &other.as_array().unwrap(); |
| 178 | let mut matches_count = 0; |
| 179 | for element in elements.iter() { |
| 180 | if self.value >= element.as_text().unwrap() { |
| 181 | matches_count += 1; |
| 182 | if GroupComparisonOperator::Any.eq(group_op) { |
| 183 | break; |
| 184 | } |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | let result = match group_op { |
| 189 | GroupComparisonOperator::All => matches_count == elements.len(), |
| 190 | GroupComparisonOperator::Any => matches_count > 0, |
| 191 | }; |
| 192 | |
| 193 | return Ok(Box::new(BoolValue::new(result))); |
| 194 | } |
| 195 | Err("Unexpected type to perform `>=` with".to_string()) |
| 196 | } |
| 197 | |
| 198 | fn lt_op(&self, other: &Box<dyn Value>) -> Result<Box<dyn Value>, String> { |
| 199 | if let Some(other_text) = other.as_any().downcast_ref::<TextValue>() { |