| 189 | } |
| 190 | |
| 191 | fn group_bang_eq_op( |
| 192 | &self, |
| 193 | other: &Box<dyn Value>, |
| 194 | group_op: &GroupComparisonOperator, |
| 195 | ) -> Result<Box<dyn Value>, String> { |
| 196 | if other.is_array_of(|element_type| element_type.is_int()) { |
| 197 | let elements = &other.as_array().unwrap(); |
| 198 | let mut matches_count = 0; |
| 199 | for element in elements.iter() { |
| 200 | if self.value != element.as_int().unwrap() { |
| 201 | matches_count += 1; |
| 202 | if GroupComparisonOperator::Any.eq(group_op) { |
| 203 | break; |
| 204 | } |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | let result = match group_op { |
| 209 | GroupComparisonOperator::All => matches_count == elements.len(), |
| 210 | GroupComparisonOperator::Any => matches_count > 0, |
| 211 | }; |
| 212 | |
| 213 | return Ok(Box::new(BoolValue::new(result))); |
| 214 | } |
| 215 | Err("Unexpected type to perform `!=` with".to_string()) |
| 216 | } |
| 217 | |
| 218 | fn gt_op(&self, other: &Box<dyn Value>) -> Result<Box<dyn Value>, String> { |
| 219 | if let Some(other_bool) = other.as_any().downcast_ref::<IntValue>() { |