| 329 | } |
| 330 | |
| 331 | fn group_lte_op( |
| 332 | &self, |
| 333 | other: &Box<dyn Value>, |
| 334 | group_op: &GroupComparisonOperator, |
| 335 | ) -> Result<Box<dyn Value>, String> { |
| 336 | if other.is_array_of(|element_type| element_type.is_int()) { |
| 337 | let elements = &other.as_array().unwrap(); |
| 338 | let mut matches_count = 0; |
| 339 | for element in elements.iter() { |
| 340 | if self.value <= element.as_int().unwrap() { |
| 341 | matches_count += 1; |
| 342 | if GroupComparisonOperator::Any.eq(group_op) { |
| 343 | break; |
| 344 | } |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | let result = match group_op { |
| 349 | GroupComparisonOperator::All => matches_count == elements.len(), |
| 350 | GroupComparisonOperator::Any => matches_count > 0, |
| 351 | }; |
| 352 | |
| 353 | return Ok(Box::new(BoolValue::new(result))); |
| 354 | } |
| 355 | Err("Unexpected type to perform `<=` with".to_string()) |
| 356 | } |
| 357 | |
| 358 | fn plus_op(&self) -> Result<Box<dyn Value>, String> { |
| 359 | Ok(Box::new(IntValue::new(self.value))) |