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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
use crate::value::Value;
use std::ops::{Rem, RemAssign};

impl<T> RemAssign<T> for Value
where
    T: Into<Value>,
{
    fn rem_assign(&mut self, rhs: T) {
        let rhs: Self = rhs.into();
        match self {
            Value::TinyInt(v) => match rhs {
                Value::TinyInt(rhs_v) => {
                    *v %= rhs_v;
                }
                _ => panic!("ops::rem type incompatible error, {:?} % {:?}", self, rhs),
            },
            Value::SmallInt(v) => match rhs {
                Value::SmallInt(rhs_v) => {
                    *v %= rhs_v;
                }
                _ => (),
            },
            Value::Int(v) => match rhs {
                Value::Int(rhs_v) => {
                    *v %= rhs_v;
                }
                _ => panic!("ops::rem type incompatible error, {:?} % {:?}", self, rhs),
            },
            Value::BigInt(v) => match rhs {
                Value::BigInt(rhs_v) => {
                    *v %= rhs_v;
                }
                _ => panic!("ops::rem type incompatible error, {:?} % {:?}", self, rhs),
            },
            #[cfg(any(feature = "sqlite", feature = "mysql"))]
            Value::TinyUnsigned(v) => match rhs {
                Value::TinyUnsigned(rhs_v) => {
                    *v %= rhs_v;
                }
                _ => panic!("ops::rem type incompatible error, {:?} % {:?}", self, rhs),
            },
            #[cfg(any(feature = "sqlite", feature = "mysql"))]
            Value::SmallUnsigned(v) => match rhs {
                Value::SmallUnsigned(rhs_v) => {
                    *v %= rhs_v;
                }
                _ => panic!("ops::rem type incompatible error, {:?} % {:?}", self, rhs),
            },
            #[cfg(any(feature = "sqlite", feature = "mysql"))]
            Value::Unsigned(v) => match rhs {
                Value::Unsigned(rhs_v) => {
                    *v %= rhs_v;
                }
                _ => panic!("ops::rem type incompatible error, {:?} % {:?}", self, rhs),
            },
            #[cfg(any(feature = "mysql"))]
            Value::BigUnsigned(v) => match rhs {
                Value::BigUnsigned(rhs_v) => {
                    *v %= rhs_v;
                }
                _ => panic!("ops::rem type incompatible error, {:?} % {:?}", self, rhs),
            },
            Value::Float(v) => match rhs {
                Value::Float(rhs_v) => {
                    *v %= rhs_v;
                }
                _ => panic!("ops::rem type incompatible error, {:?} % {:?}", self, rhs),
            },
            Value::Double(v) => match rhs {
                Value::Double(rhs_v) => {
                    *v %= rhs_v;
                }
                _ => panic!("ops::rem type incompatible error, {:?} % {:?}", self, rhs),
            },
            _ => panic!("ops::rem type not support, {:?} % {:?}", self, rhs),
        }
    }
}

/// # Examples
///
/// ```
/// use arel::prelude::*;
/// let sub_v1: arel::sub_value::ValueInt = 1.into();
/// let sub_v2: arel::sub_value::ValueInt = 2.into();
/// let v1: arel::Value = sub_v1.into();
/// let v2: arel::Value = sub_v2.into();
/// assert_eq!(v1 + v2, arel::Value::Int(3.into()));
///```

impl<T> Rem<T> for Value
where
    T: Into<Value>,
{
    type Output = Self;
    fn rem(mut self, rhs: T) -> Self::Output {
        let rhs: Self = rhs.into();
        self %= rhs;
        self
    }
}