| 154 | } |
| 155 | |
| 156 | fn group_eq_op( |
| 157 | &self, |
| 158 | other: &Box<dyn Value>, |
| 159 | group_op: &GroupComparisonOperator, |
| 160 | ) -> Result<Box<dyn Value>, String> { |
| 161 | if other.is_array_of(|element_type| element_type.is_int()) { |
| 162 | let elements = &other.as_array().unwrap(); |
| 163 | let mut matches_count = 0; |
| 164 | for element in elements.iter() { |
| 165 | if self.value == element.as_int().unwrap() { |
| 166 | matches_count += 1; |
| 167 | if GroupComparisonOperator::Any.eq(group_op) { |
| 168 | break; |
| 169 | } |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | let result = match group_op { |
| 174 | GroupComparisonOperator::All => matches_count == elements.len(), |
| 175 | GroupComparisonOperator::Any => matches_count > 0, |
| 176 | }; |
| 177 | |
| 178 | return Ok(Box::new(BoolValue::new(result))); |
| 179 | } |
| 180 | Err("Unexpected type to perform `=` with".to_string()) |
| 181 | } |
| 182 | |
| 183 | fn bang_eq_op(&self, other: &Box<dyn Value>) -> Result<Box<dyn Value>, String> { |
| 184 | if let Some(other_bool) = other.as_any().downcast_ref::<IntValue>() { |