# Consider splitting \[Partial\]Eq/Ord into separate traits/operators

**URL:** <https://internals.rust-lang.org/t/consider-splitting-partial-eq-ord-into-separate-traits-operators/19695>\
**Category:** language design\
**Created:** [October 11, 2023, 12:50pm UTC](https://internals.rust-lang.org/t/consider-splitting-partial-eq-ord-into-separate-traits-operators/19695 "2023-10-11T12:50:57Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![mathstuf](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@mathstuf](https://internals.rust-lang.org/u/mathstuf)\
**Post date:** [October 11, 2023, 10:14pm UTC](https://internals.rust-lang.org/t/consider-splitting-partial-eq-ord-into-separate-traits-operators/19695/4 "2023-10-11T22:14:17Z")

</div>

While expression templates are neat, I don't think I'd trade them for the current set of operator traits due to the "trust" they allow me to currently have when reading code. Not to mention that in your example,

> [@DanB](#):
>
> `solve([x + 2 == x.pow(2), x > 4, x <= 20], [x]);`

would need to have that first argument have consistent types, probably `Box<dyn Expression>` which would require wrapping in `Box::new(arg) as Box<dyn Expression>` (though maybe type inference can elide the `as` part). I suppose you could have this be a huge `enum`, but then it would be full of `Box`es due to the recursive nature of just about every operator. I feel like a macro that matches on the tokens of the operators and builds the tree that way would work better myself. You could even then have `x**2` instead of `x.pow(2)`. Or `2**x` instead of the (otherwise impossible) `2.pow(x)`.

> [@DanB](#):
>
> `// or, if && and || were overloadable, then perhaps:`

See these threads:

- [`ControlFlow`: The Answer to `BoolAnd`/`BoolOr`](https://internals.rust-lang.org/t/controlflow-the-answer-to-booland-boolor/19608)
- [A different way to override || and &&](https://internals.rust-lang.org/t/a-different-way-to-override-and/14627)
- [Pre-RFC: Overload Short Curcuits](https://internals.rust-lang.org/t/pre-rfc-overload-short-curcuits/10460)

Prior discussion:

- [[Pre-RFC] Boolean operators that don't return bool](https://internals.rust-lang.org/t/pre-rfc-boolean-operators-that-dont-return-bool/1684)

---

_[View the full topic](https://internals.rust-lang.org/t/consider-splitting-partial-eq-ord-into-separate-traits-operators/19695)._
