MCPcopy Create free account
hub / github.com/AmrDeveloper/GQL / group_lte_op

Method group_lte_op

crates/gitql-core/src/values/boolean.rs:259–284  ·  view source on GitHub ↗
(
        &self,
        other: &Box<dyn Value>,
        group_op: &GroupComparisonOperator,
    )

Source from the content-addressed store, hash-verified

257 }
258
259 fn group_lte_op(
260 &self,
261 other: &Box<dyn Value>,
262 group_op: &GroupComparisonOperator,
263 ) -> Result<Box<dyn Value>, String> {
264 if other.is_array_of(|element_type| element_type.is_bool()) {
265 let elements = &other.as_array().unwrap();
266 let mut matches_count = 0;
267 for element in elements.iter() {
268 if self.value <= element.as_bool().unwrap() {
269 matches_count += 1;
270 if GroupComparisonOperator::Any.eq(group_op) {
271 break;
272 }
273 }
274 }
275
276 let result = match group_op {
277 GroupComparisonOperator::All => matches_count == elements.len(),
278 GroupComparisonOperator::Any => matches_count > 0,
279 };
280
281 return Ok(Box::new(BoolValue::new(result)));
282 }
283 Err("Unexpected type to perform `<=` with".to_string())
284 }
285
286 fn not_op(&self) -> Result<Box<dyn Value>, String> {
287 Ok(Box::new(BoolValue::new(!self.value)))

Callers

nothing calls this directly

Calls 6

is_array_ofMethod · 0.80
as_arrayMethod · 0.80
as_boolMethod · 0.80
is_boolMethod · 0.45
eqMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected