rbatis_codegen/
ops_neg.rs

1use crate::ops::Neg;
2
3use rbs::Value;
4
5fn op_neg(left: Value) -> Value {
6    use std::ops::Neg;
7    match left {
8        Value::I32(b) => Value::I32(b.neg()),
9        Value::I64(b) => Value::I64(b.neg()),
10        Value::F32(b) => Value::F32(b.neg()),
11        Value::F64(b) => Value::F64(b.neg()),
12        Value::Ext(_, e) => op_neg(*e),
13        _ => Value::Null,
14    }
15}
16
17impl Neg for Value {
18    type Output = Value;
19
20    fn neg(self) -> Self::Output {
21        op_neg(self)
22    }
23}
24
25impl Neg for &Value {
26    type Output = Value;
27    fn neg(self) -> Self::Output {
28        op_neg(self.to_owned())
29    }
30}
31
32impl Neg for &&Value {
33    type Output = Value;
34    fn neg(self) -> Self::Output {
35        op_neg((*self).to_owned())
36    }
37}
38
39impl Neg for &mut Value {
40    type Output = Value;
41    fn neg(self) -> Self::Output {
42        op_neg(self.to_owned())
43    }
44}