From 4838a21a5750b52b7d840b7bcad4ed9cbe33edb0 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Thu, 28 Mar 2019 11:14:55 +0100 Subject: [PATCH] Add default implementation for `Operator::is_left_to_right` --- src/operator/mod.rs | 84 ++------------------------------------------- 1 file changed, 3 insertions(+), 81 deletions(-) diff --git a/src/operator/mod.rs b/src/operator/mod.rs index 330c728..af5d9eb 100644 --- a/src/operator/mod.rs +++ b/src/operator/mod.rs @@ -16,7 +16,9 @@ pub trait Operator: Debug + Display { /// and false if they should be evaluated right-to-left. /// Left-to-right chaining has priority if operators with different order but same precedence are chained. // Make this a const fn once #57563 is resolved - fn is_left_to_right(&self) -> bool; + fn is_left_to_right(&self) -> bool { + true + } /// True if this operator is a leaf, meaning it accepts no arguments. // Make this a const fn once #57563 is resolved @@ -118,10 +120,6 @@ impl Operator for RootNode { 200 } - fn is_left_to_right(&self) -> bool { - true - } - fn max_argument_amount(&self) -> usize { 1 } @@ -140,10 +138,6 @@ impl Operator for Add { 95 } - fn is_left_to_right(&self) -> bool { - true - } - fn max_argument_amount(&self) -> usize { 2 } @@ -176,10 +170,6 @@ impl Operator for Sub { 95 } - fn is_left_to_right(&self) -> bool { - true - } - fn max_argument_amount(&self) -> usize { 2 } @@ -212,10 +202,6 @@ impl Operator for Neg { 110 } - fn is_left_to_right(&self) -> bool { - true - } - fn max_argument_amount(&self) -> usize { 1 } @@ -242,10 +228,6 @@ impl Operator for Mul { 100 } - fn is_left_to_right(&self) -> bool { - true - } - fn max_argument_amount(&self) -> usize { 2 } @@ -278,10 +260,6 @@ impl Operator for Div { 100 } - fn is_left_to_right(&self) -> bool { - true - } - fn max_argument_amount(&self) -> usize { 2 } @@ -314,10 +292,6 @@ impl Operator for Mod { 100 } - fn is_left_to_right(&self) -> bool { - true - } - fn max_argument_amount(&self) -> usize { 2 } @@ -350,10 +324,6 @@ impl Operator for Exp { 120 } - fn is_left_to_right(&self) -> bool { - true - } - fn max_argument_amount(&self) -> usize { 2 } @@ -377,10 +347,6 @@ impl Operator for Eq { 80 } - fn is_left_to_right(&self) -> bool { - true - } - fn max_argument_amount(&self) -> usize { 2 } @@ -401,10 +367,6 @@ impl Operator for Neq { 80 } - fn is_left_to_right(&self) -> bool { - true - } - fn max_argument_amount(&self) -> usize { 2 } @@ -425,10 +387,6 @@ impl Operator for Gt { 80 } - fn is_left_to_right(&self) -> bool { - true - } - fn max_argument_amount(&self) -> usize { 2 } @@ -459,10 +417,6 @@ impl Operator for Lt { 80 } - fn is_left_to_right(&self) -> bool { - true - } - fn max_argument_amount(&self) -> usize { 2 } @@ -493,10 +447,6 @@ impl Operator for Geq { 80 } - fn is_left_to_right(&self) -> bool { - true - } - fn max_argument_amount(&self) -> usize { 2 } @@ -527,10 +477,6 @@ impl Operator for Leq { 80 } - fn is_left_to_right(&self) -> bool { - true - } - fn max_argument_amount(&self) -> usize { 2 } @@ -561,10 +507,6 @@ impl Operator for And { 75 } - fn is_left_to_right(&self) -> bool { - true - } - fn max_argument_amount(&self) -> usize { 2 } @@ -587,10 +529,6 @@ impl Operator for Or { 70 } - fn is_left_to_right(&self) -> bool { - true - } - fn max_argument_amount(&self) -> usize { 2 } @@ -613,10 +551,6 @@ impl Operator for Not { 110 } - fn is_left_to_right(&self) -> bool { - true - } - fn max_argument_amount(&self) -> usize { 1 } @@ -638,10 +572,6 @@ impl Operator for Tuple { 40 } - fn is_left_to_right(&self) -> bool { - true - } - fn max_argument_amount(&self) -> usize { 2 } @@ -702,10 +632,6 @@ impl Operator for Const { 200 } - fn is_left_to_right(&self) -> bool { - true - } - fn max_argument_amount(&self) -> usize { 0 } @@ -722,10 +648,6 @@ impl Operator for VariableIdentifier { 200 } - fn is_left_to_right(&self) -> bool { - true - } - fn max_argument_amount(&self) -> usize { 0 }