| 267 | } |
| 268 | |
| 269 | fn group_lte_op( |
| 270 | &self, |
| 271 | other: &Box<dyn Value>, |
| 272 | group_op: &GroupComparisonOperator, |
| 273 | ) -> Result<Box<dyn Value>, String> { |
| 274 | if other.is_array_of(|element_type| element_type.is_float()) { |
| 275 | let elements = &other.as_array().unwrap(); |
| 276 | let mut matches_count = 0; |
| 277 | for element in elements.iter() { |
| 278 | if self.value <= element.as_float().unwrap() { |
| 279 | matches_count += 1; |
| 280 | if GroupComparisonOperator::Any.eq(group_op) { |
| 281 | break; |
| 282 | } |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | let result = match group_op { |
| 287 | GroupComparisonOperator::All => matches_count == elements.len(), |
| 288 | GroupComparisonOperator::Any => matches_count > 0, |
| 289 | }; |
| 290 | |
| 291 | return Ok(Box::new(BoolValue::new(result))); |
| 292 | } |
| 293 | Err("Unexpected type to perform `<=` with".to_string()) |
| 294 | } |
| 295 | |
| 296 | fn cast_op(&self, target_type: &Box<dyn DataType>) -> Result<Box<dyn Value>, String> { |
| 297 | // Cast Integer |