use crate::value::Value;
use std::ops::{Div, DivAssign};
impl<T> DivAssign<T> for Value
where
T: Into<Value>,
{
fn div_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::div 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::div type incompatible error, {:?} / {:?}", self, rhs),
},
Value::BigInt(v) => match rhs {
Value::BigInt(rhs_v) => {
*v /= rhs_v;
}
_ => panic!("ops::div 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::div 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::div 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::div type incompatible error, {:?} / {:?}", self, rhs),
},
#[cfg(any(feature = "mysql"))]
Value::BigUnsigned(v) => match rhs {
Value::BigUnsigned(rhs_v) => {
*v /= rhs_v;
}
_ => panic!("ops::div type incompatible error, {:?} / {:?}", self, rhs),
},
Value::Float(v) => match rhs {
Value::Float(rhs_v) => {
*v /= rhs_v;
}
_ => panic!("ops::div type incompatible error, {:?} / {:?}", self, rhs),
},
Value::Double(v) => match rhs {
Value::Double(rhs_v) => {
*v /= rhs_v;
}
_ => panic!("ops::div type incompatible error, {:?} / {:?}", self, rhs),
},
_ => panic!("ops::div type not support, {:?} / {:?}", self, rhs),
}
}
}
impl<T> Div<T> for Value
where
T: Into<Value>,
{
type Output = Self;
fn div(mut self, rhs: T) -> Self::Output {
let rhs: Self = rhs.into();
self /= rhs;
self
}
}