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