I had created a single enum called Expr to represent the result of all these branches, and kept its variants on the basis of the number of operators and operands they take.
Here, the Token is the operator that is associated with both the operands (which themselves are Expr). Not sure if it’s the most idiomatic way to do the same, but worked well for me.
Can’t blame you for that. Coming from other languages like Typescript and even CPP, enums have a reputation of being glorified constants. But in Rust, they are one of the most powerful concepts because of ability of store different shapes of data and pattern matching expressiveness!