| 121 | } |
| 122 | |
| 123 | fn group_bang_eq_op( |
| 124 | &self, |
| 125 | other: &Box<dyn Value>, |
| 126 | group_op: &GroupComparisonOperator, |
| 127 | ) -> Result<Box<dyn Value>, String> { |
| 128 | if other.is_array_of(|element_type| element_type.is_bool()) { |
| 129 | let elements = &other.as_array().unwrap(); |
| 130 | let mut matches_count = 0; |
| 131 | for element in elements.iter() { |
| 132 | if self.value != element.as_bool().unwrap() { |
| 133 | matches_count += 1; |
| 134 | if GroupComparisonOperator::Any.eq(group_op) { |
| 135 | break; |
| 136 | } |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | let result = match group_op { |
| 141 | GroupComparisonOperator::All => matches_count == elements.len(), |
| 142 | GroupComparisonOperator::Any => matches_count > 0, |
| 143 | }; |
| 144 | |
| 145 | return Ok(Box::new(BoolValue::new(result))); |
| 146 | } |
| 147 | Err("Unexpected type to perform `!=` with".to_string()) |
| 148 | } |
| 149 | |
| 150 | fn gt_op(&self, other: &Box<dyn Value>) -> Result<Box<dyn Value>, String> { |
| 151 | if let Some(other_bool) = other.as_any().downcast_ref::<BoolValue>() { |