mirror of
https://github.com/nushell/nushell
synced 2025-01-10 12:19:14 +00:00
48 lines
1.3 KiB
Rust
48 lines
1.3 KiB
Rust
use std::fmt::Display;
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub enum Operator {
|
|
Equal,
|
|
NotEqual,
|
|
LessThan,
|
|
GreaterThan,
|
|
LessThanOrEqual,
|
|
GreaterThanOrEqual,
|
|
Contains,
|
|
NotContains,
|
|
Plus,
|
|
Minus,
|
|
Multiply,
|
|
Divide,
|
|
In,
|
|
NotIn,
|
|
Modulo,
|
|
And,
|
|
Or,
|
|
Pow,
|
|
}
|
|
|
|
impl Display for Operator {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
match self {
|
|
Operator::Equal => write!(f, "=="),
|
|
Operator::NotEqual => write!(f, "!="),
|
|
Operator::LessThan => write!(f, "<"),
|
|
Operator::GreaterThan => write!(f, ">"),
|
|
Operator::Contains => write!(f, "=~"),
|
|
Operator::NotContains => write!(f, "!~"),
|
|
Operator::Plus => write!(f, "+"),
|
|
Operator::Minus => write!(f, "-"),
|
|
Operator::Multiply => write!(f, "*"),
|
|
Operator::Divide => write!(f, "/"),
|
|
Operator::In => write!(f, "in"),
|
|
Operator::NotIn => write!(f, "not-in"),
|
|
Operator::Modulo => write!(f, "mod"),
|
|
Operator::And => write!(f, "&&"),
|
|
Operator::Or => write!(f, "||"),
|
|
Operator::Pow => write!(f, "**"),
|
|
Operator::LessThanOrEqual => write!(f, "<="),
|
|
Operator::GreaterThanOrEqual => write!(f, ">="),
|
|
}
|
|
}
|
|
}
|