| 230 | } |
| 231 | |
| 232 | fn group_lte_op( |
| 233 | &self, |
| 234 | other: &Box<dyn Value>, |
| 235 | group_op: &GroupComparisonOperator, |
| 236 | ) -> Result<Box<dyn Value>, String> { |
| 237 | if other.is_array_of(|element_type| element_type.is_time()) { |
| 238 | let elements = &other.as_array().unwrap(); |
| 239 | let mut matches_count = 0; |
| 240 | for element in elements.iter() { |
| 241 | if self.value <= element.as_time().unwrap() { |
| 242 | matches_count += 1; |
| 243 | if GroupComparisonOperator::Any.eq(group_op) { |
| 244 | break; |
| 245 | } |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | let result = match group_op { |
| 250 | GroupComparisonOperator::All => matches_count == elements.len(), |
| 251 | GroupComparisonOperator::Any => matches_count > 0, |
| 252 | }; |
| 253 | |
| 254 | return Ok(Box::new(BoolValue::new(result))); |
| 255 | } |
| 256 | Err("Unexpected type to perform `<=` with".to_string()) |
| 257 | } |
| 258 | } |