Why Rust does not provide several custom operators?

I think one could entertain the thought of adding just one more operator: The infix function call operator, let's call it \ for the purposes of the discussion.

So that we can write:

use ndarray::op;

let c = A \op B;

And this A \op B becomes equivalent to op(A, B). op is just a function!

It's not a complete suggestion yet - taking references or not, autoref, is tricky. But I always though it would be very powerful to just re-use functions this way. A properly defined function can be an infix operator with the new \ operator. It would make it very easy for crates to define their own operators (and traits for them!) with the minimum of language machinery.

6 Likes