use crate::ast::CallStyle;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone, Copy, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub enum UnaryOp {
Not,
Neg,
}
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone, Copy, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub enum BinaryOp {
Eq,
Less,
LessEq,
Add,
Sub,
Mul,
In,
Contains,
ContainsAll,
ContainsAny,
}
impl std::fmt::Display for UnaryOp {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
UnaryOp::Not => write!(f, "!_"),
UnaryOp::Neg => write!(f, "-_"),
}
}
}
impl std::fmt::Display for BinaryOp {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
BinaryOp::Eq => write!(f, "_==_"),
BinaryOp::Less => write!(f, "_<_"),
BinaryOp::LessEq => write!(f, "_<=_"),
BinaryOp::Add => write!(f, "_+_"),
BinaryOp::Sub => write!(f, "_-_"),
BinaryOp::Mul => write!(f, "_*_"),
BinaryOp::In => write!(f, "_in_"),
BinaryOp::Contains => write!(f, "contains"),
BinaryOp::ContainsAll => write!(f, "containsAll"),
BinaryOp::ContainsAny => write!(f, "containsAny"),
}
}
}
impl std::fmt::Display for CallStyle {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::FunctionStyle => write!(f, "function-style"),
Self::MethodStyle => write!(f, "method-style"),
}
}
}