use super::{BinaryOperator, UnaryOperator, WriteSql};
#[cfg_attr(any(feature = "fmt", test, debug_assertions), derive(Debug))]
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum MathBi {
Add,
Sub,
Mult,
Div,
Mod,
BitAnd,
BitOr,
BitXor,
ShiftLeft,
ShiftRight,
}
impl MathBi {
pub const fn as_str(&self) -> &'static str {
match *self {
Self::Add => "+",
Self::Sub => "-",
Self::Mult => "*",
Self::Div => "/",
Self::Mod => "%",
Self::BitAnd => "&",
Self::BitOr => "|",
Self::BitXor => "^",
Self::ShiftLeft => "<<",
Self::ShiftRight => ">>",
}
}
}
impl super::private::Sealed for MathBi {}
impl BinaryOperator for MathBi {
fn push_operator<Sql, Arg>(&self, sql: &mut Sql)
where
Sql: WriteSql<Arg>,
{
sql.push_cmd(self.as_str())
}
}
#[cfg_attr(any(feature = "fmt", test, debug_assertions), derive(Debug))]
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum MathUnary {
Neg,
BitNot,
}
impl MathUnary {
pub const fn as_str(&self) -> &'static str {
match *self {
Self::Neg => "!",
Self::BitNot => "~",
}
}
}
impl super::private::Sealed for MathUnary {}
impl UnaryOperator for MathUnary {
fn push_operator<Sql, Arg>(&self, sql: &mut Sql)
where
Sql: WriteSql<Arg>,
{
sql.push_cmd(self.as_str())
}
}
#[cfg_attr(any(feature = "fmt", test, debug_assertions), derive(Debug))]
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum MathFn {
Sqrt,
Exp,
Factorial,
Abs,
}