forked from extern/nushell
Add logical xor
operator (#7242)
We already have the binary `bit-xor` and the shortcircuiting logical `or`(`||`) and `and`(`&&`). This introduces `xor` as a compact form for both brevity and clarity. You can express the operation through `not`/`and`/`or` with a slight risk of introducing bugs through typos. Operator precedence `and` > `xor` > `or` Added logic and precedence tests.
This commit is contained in:
committed by
GitHub
parent
3e76ed9122
commit
2ccb91dc6a
@ -35,6 +35,7 @@ pub enum Math {
|
||||
pub enum Boolean {
|
||||
And,
|
||||
Or,
|
||||
Xor,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
@ -94,6 +95,7 @@ impl Display for Operator {
|
||||
Operator::Math(Math::Pow) => write!(f, "**"),
|
||||
Operator::Boolean(Boolean::And) => write!(f, "&&"),
|
||||
Operator::Boolean(Boolean::Or) => write!(f, "||"),
|
||||
Operator::Boolean(Boolean::Xor) => write!(f, "xor"),
|
||||
Operator::Bits(Bits::BitOr) => write!(f, "bit-or"),
|
||||
Operator::Bits(Bits::BitXor) => write!(f, "bit-xor"),
|
||||
Operator::Bits(Bits::BitAnd) => write!(f, "bit-and"),
|
||||
|
Reference in New Issue
Block a user