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