MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / apply_binop

Function apply_binop

nodedb/src/control/promql/evaluator/binary.rs:97–113  ·  view source on GitHub ↗
(op: BinOp, a: f64, b: f64, return_bool: bool)

Source from the content-addressed store, hash-verified

95}
96
97fn apply_binop(op: BinOp, a: f64, b: f64, return_bool: bool) -> f64 {
98 match op {
99 BinOp::Add => a + b,
100 BinOp::Sub => a - b,
101 BinOp::Mul => a * b,
102 BinOp::Div => a / b,
103 BinOp::Mod => a % b,
104 BinOp::Pow => a.powf(b),
105 BinOp::Eq => bool_result(a == b, return_bool, a),
106 BinOp::Neq => bool_result(a != b, return_bool, a),
107 BinOp::Lt => bool_result(a < b, return_bool, a),
108 BinOp::Gt => bool_result(a > b, return_bool, a),
109 BinOp::Lte => bool_result(a <= b, return_bool, a),
110 BinOp::Gte => bool_result(a >= b, return_bool, a),
111 BinOp::And | BinOp::Or | BinOp::Unless => a,
112 }
113}
114
115fn bool_result(cond: bool, return_bool: bool, original: f64) -> f64 {
116 if return_bool {

Callers 2

eval_binary_opFunction · 0.85
eval_vector_binopFunction · 0.85

Calls 1

bool_resultFunction · 0.85

Tested by

no test coverage detected