rbatis_codegen/
ops_neg.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use crate::ops::Neg;

use rbs::Value;

fn op_neg(left: Value) -> Value {
    use std::ops::Neg;
    match left {
        Value::I32(b) => Value::I32(b.neg()),
        Value::I64(b) => Value::I64(b.neg()),
        Value::F32(b) => Value::F32(b.neg()),
        Value::F64(b) => Value::F64(b.neg()),
        Value::Ext(_, e) => op_neg(*e),
        _ => Value::Null,
    }
}

impl Neg for Value {
    type Output = Value;

    fn neg(self) -> Self::Output {
        op_neg(self)
    }
}

impl Neg for &Value {
    type Output = Value;
    fn neg(self) -> Self::Output {
        op_neg(self.to_owned())
    }
}

impl Neg for &mut Value {
    type Output = Value;
    fn neg(self) -> Self::Output {
        op_neg(self.to_owned())
    }
}