| 55 | } |
| 56 | |
| 57 | fn group_eq_op( |
| 58 | &self, |
| 59 | other: &Box<dyn Value>, |
| 60 | group_op: &GroupComparisonOperator, |
| 61 | ) -> Result<Box<dyn Value>, String> { |
| 62 | if other.is_array_of(|element_type| element_type.is_time()) { |
| 63 | let elements = &other.as_array().unwrap(); |
| 64 | let mut matches_count = 0; |
| 65 | for element in elements.iter() { |
| 66 | if self.value == element.as_time().unwrap() { |
| 67 | matches_count += 1; |
| 68 | if GroupComparisonOperator::Any.eq(group_op) { |
| 69 | break; |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | let result = match group_op { |
| 75 | GroupComparisonOperator::All => matches_count == elements.len(), |
| 76 | GroupComparisonOperator::Any => matches_count > 0, |
| 77 | }; |
| 78 | |
| 79 | return Ok(Box::new(BoolValue::new(result))); |
| 80 | } |
| 81 | Err("Unexpected type to perform `=` with".to_string()) |
| 82 | } |
| 83 | |
| 84 | fn bang_eq_op(&self, other: &Box<dyn Value>) -> Result<Box<dyn Value>, String> { |
| 85 | if let Some(other_text) = other.as_any().downcast_ref::<TimeValue>() { |