fn operator_string_to_func(op: &str, op_is_negated: NegOp, val: f64) -> Box<dyn Fn(f64) -> bool> {
    let comp: Box<dyn Fn(f64) -> bool> = match op {
        "<" => Box::new(move |i: f64| i < val),
        "<=" => Box::new(move |i: f64| i <= val),
        ">" => Box::new(move |i: f64| i > val),
        ">=" => Box::new(move |i: f64| i >= val),
        "==" => Box::new(move |i: f64| i == val),
        "!=" => Box::new(move |i: f64| i != val),
        a => panic!("Bad operator: {}", a),
    };

    if op_is_negated == NegOp::Yes {
        Box::new(move |i: f64| !comp(i))
    } else {
        comp
    }
}
/// Take an operator and a value and return a function that can be used in a
/// filter to return only values that *do not* satisfy the operator.
///
/// aka a function that returns only invalid numbers
///
/// Note: JSON considers all numbers either floats or arbitrary-precision
/// decimals, so we use f64. Comparing f64 directly equal with each other is dangerous.
///
/// We aren't ever actually doing math on floats, so even though decimal 0.1 !=
/// float 0.1, since we are always interpreting as f64 then we'll get the
/// "wrong" values and compare them to each other. That said, we should
/// probably use an epsilon in here.
Take an operator and a value and return a function that can be used in a
filter to return only values that *do not* satisfy the operator.

aka a function that returns only invalid numbers

JSON considers all numbers either floats or arbitrary-precision
decimals, so we use f64. Comparing f64 directly equal with each other is dangerous.

We aren't ever actually doing math on floats, so even though decimal 0.1 .
float 0.1, since we are always interpreting as f64 then we'll get the
"wrong" values and compare them to each other. That said, we should
probably use an epsilon in here.
Take an operator and a value and return a function that can be used in a filter to return only values that * do not * satisfy the operator . aka a function that returns only invalid numbers JSON considers all numbers either floats or arbitrary - precision decimals so we use f64 . Comparing f64 directly equal with each other is dangerous . We aren ' t ever actually doing math on floats so even though decimal 0 . 1 . float 0 . 1 since we are always interpreting as f64 then we ' ll get the " wrong " values and compare them to each other . That said we should probably use an epsilon in here .
fn operator_string_to_func(op: &str, op_is_negated: NegOp, val: f64) -> Box<dyn Fn(f64) -> bool> {
    let comp: Box<dyn Fn(f64) -> bool> = match op {
        "<" => Box::new(move |i: f64| i < val),
        "<=" => Box::new(move |i: f64| i <= val),
        ">" => Box::new(move |i: f64| i > val),
        ">=" => Box::new(move |i: f64| i >= val),
        "==" => Box::new(move |i: f64| i == val),
        "!=" => Box::new(move |i: f64| i != val),
        a => panic!("Bad operator: {}", a),
    };
    if op_is_negated == NegOp::Yes {
        Box::new(move |i: f64| !comp(i))
    } else {
        comp
    }
}
fn operator_string_to_func ( op : & str , op_is_negated : NegOp , val : f64 ) -> Box < dyn Fn ( f64 ) -> bool > { let comp : Box < dyn Fn ( f64 ) -> bool > = match op { " " => Box :: new ( move | i : f64 | i < val ) , " " => Box :: new ( move | i : f64 | i <= val ) , " " => Box :: new ( move | i : f64 | i > val ) , " " => Box :: new ( move | i : f64 | i >= val ) , " " => Box :: new ( move | i : f64 | i == val ) , " " => Box :: new ( move | i : f64 | i != val ) , a => panic ! ( " " a ) , } ; if op_is_negated == NegOp :: Yes { Box :: new ( move | i : f64 | ! comp ( i ) ) } else { comp } }
Take an operator and a value and return a function that can be used in a
filter to return only values that *do not* satisfy the operator.
Take an operator and a value and return a function that can be used in a filter to return only values that * do not * satisfy the operator .
op
&str
op_is_negated
NegOp
val
f64
op
&str
op_is_negated
NegOp
val
f64