| 203 | } |
| 204 | |
| 205 | fn group_lt_op( |
| 206 | &self, |
| 207 | other: &Box<dyn Value>, |
| 208 | group_op: &GroupComparisonOperator, |
| 209 | ) -> Result<Box<dyn Value>, String> { |
| 210 | if other.is_array_of(|element_type| element_type.is_text()) { |
| 211 | let elements = &other.as_array().unwrap(); |
| 212 | let mut matches_count = 0; |
| 213 | for element in elements.iter() { |
| 214 | if self.value < element.as_text().unwrap() { |
| 215 | matches_count += 1; |
| 216 | if GroupComparisonOperator::Any.eq(group_op) { |
| 217 | break; |
| 218 | } |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | let result = match group_op { |
| 223 | GroupComparisonOperator::All => matches_count == elements.len(), |
| 224 | GroupComparisonOperator::Any => matches_count > 0, |
| 225 | }; |
| 226 | |
| 227 | return Ok(Box::new(BoolValue::new(result))); |
| 228 | } |
| 229 | Err("Unexpected type to perform `<` with".to_string()) |
| 230 | } |
| 231 | |
| 232 | fn lte_op(&self, other: &Box<dyn Value>) -> Result<Box<dyn Value>, String> { |
| 233 | if let Some(other_text) = other.as_any().downcast_ref::<TextValue>() { |