| 294 | } |
| 295 | |
| 296 | fn group_lt_op( |
| 297 | &self, |
| 298 | other: &Box<dyn Value>, |
| 299 | group_op: &GroupComparisonOperator, |
| 300 | ) -> Result<Box<dyn Value>, String> { |
| 301 | if other.is_array_of(|element_type| element_type.is_int()) { |
| 302 | let elements = &other.as_array().unwrap(); |
| 303 | let mut matches_count = 0; |
| 304 | for element in elements.iter() { |
| 305 | if self.value < element.as_int().unwrap() { |
| 306 | matches_count += 1; |
| 307 | if GroupComparisonOperator::Any.eq(group_op) { |
| 308 | break; |
| 309 | } |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | let result = match group_op { |
| 314 | GroupComparisonOperator::All => matches_count == elements.len(), |
| 315 | GroupComparisonOperator::Any => matches_count > 0, |
| 316 | }; |
| 317 | |
| 318 | return Ok(Box::new(BoolValue::new(result))); |
| 319 | } |
| 320 | Err("Unexpected type to perform `<` with".to_string()) |
| 321 | } |
| 322 | |
| 323 | fn lte_op(&self, other: &Box<dyn Value>) -> Result<Box<dyn Value>, String> { |
| 324 | if let Some(other_bool) = other.as_any().downcast_ref::<IntValue>() { |