| 223 | } |
| 224 | |
| 225 | fn group_lt_op( |
| 226 | &self, |
| 227 | other: &Box<dyn Value>, |
| 228 | group_op: &GroupComparisonOperator, |
| 229 | ) -> Result<Box<dyn Value>, String> { |
| 230 | if other.is_array_of(|element_type| element_type.is_bool()) { |
| 231 | let elements = &other.as_array().unwrap(); |
| 232 | let mut matches_count = 0; |
| 233 | for element in elements.iter() { |
| 234 | if !self.value & element.as_bool().unwrap() { |
| 235 | matches_count += 1; |
| 236 | if GroupComparisonOperator::Any.eq(group_op) { |
| 237 | break; |
| 238 | } |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | let result = match group_op { |
| 243 | GroupComparisonOperator::All => matches_count == elements.len(), |
| 244 | GroupComparisonOperator::Any => matches_count > 0, |
| 245 | }; |
| 246 | |
| 247 | return Ok(Box::new(BoolValue::new(result))); |
| 248 | } |
| 249 | Err("Unexpected type to perform `<` with".to_string()) |
| 250 | } |
| 251 | |
| 252 | fn lte_op(&self, other: &Box<dyn Value>) -> Result<Box<dyn Value>, String> { |
| 253 | if let Some(other_bool) = other.as_any().downcast_ref::<BoolValue>() { |