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

Method group_lte_op

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

Source from the content-addressed store, hash-verified

267 }
268
269 fn group_lte_op(
270 &self,
271 other: &Box<dyn Value>,
272 group_op: &GroupComparisonOperator,
273 ) -> Result<Box<dyn Value>, String> {
274 if other.is_array_of(|element_type| element_type.is_float()) {
275 let elements = &other.as_array().unwrap();
276 let mut matches_count = 0;
277 for element in elements.iter() {
278 if self.value <= element.as_float().unwrap() {
279 matches_count += 1;
280 if GroupComparisonOperator::Any.eq(group_op) {
281 break;
282 }
283 }
284 }
285
286 let result = match group_op {
287 GroupComparisonOperator::All => matches_count == elements.len(),
288 GroupComparisonOperator::Any => matches_count > 0,
289 };
290
291 return Ok(Box::new(BoolValue::new(result)));
292 }
293 Err("Unexpected type to perform `<=` with".to_string())
294 }
295
296 fn cast_op(&self, target_type: &Box<dyn DataType>) -> Result<Box<dyn Value>, String> {
297 // Cast Integer

Callers

nothing calls this directly

Calls 6

is_array_ofMethod · 0.80
as_arrayMethod · 0.80
as_floatMethod · 0.80
is_floatMethod · 0.45
eqMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected