| 87 | } |
| 88 | |
| 89 | fn group_eq_op( |
| 90 | &self, |
| 91 | other: &Box<dyn Value>, |
| 92 | group_op: &GroupComparisonOperator, |
| 93 | ) -> Result<Box<dyn Value>, String> { |
| 94 | if other.is_array_of(|element_type| element_type.is_bool()) { |
| 95 | let elements = &other.as_array().unwrap(); |
| 96 | let mut matches_count = 0; |
| 97 | for element in elements.iter() { |
| 98 | if self.value == element.as_bool().unwrap() { |
| 99 | matches_count += 1; |
| 100 | if GroupComparisonOperator::Any.eq(group_op) { |
| 101 | break; |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | let result = match group_op { |
| 107 | GroupComparisonOperator::All => matches_count == elements.len(), |
| 108 | GroupComparisonOperator::Any => matches_count > 0, |
| 109 | }; |
| 110 | |
| 111 | return Ok(Box::new(BoolValue::new(result))); |
| 112 | } |
| 113 | Err("Unexpected type to perform `=` with".to_string()) |
| 114 | } |
| 115 | |
| 116 | fn bang_eq_op(&self, other: &Box<dyn Value>) -> Result<Box<dyn Value>, String> { |
| 117 | if let Some(other_bool) = other.as_any().downcast_ref::<BoolValue>() { |