Expressing exponent for custom Struct

I have:

pub struct MathNode {}

I have also implemented traits relating to: +, -, *, /, ^

Unfortunately, the precedence level shown in Expressions - The Rust Reference is not what I want -- I'd prefer ^ to have higher precedence than all of +-*/

What is the best way to deal with this?

You can't change precedence, so you have to pick another operator that has the precedence you want, or live with a wrong precedence.

1 Like

Another way is to write a proc macro. You can design syntax whatever you want but a downside is that it can confuse code readers.

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.