Infix operators

Can one define new infix (dyadic) operators in Rust?

No. You can only recycle the existing ones by implementing the corresponding traits.

… and if you expect anyone else to be able to use or maintain or modify your code, you should limit the semantics of such overloaded operators to be somewhat analogous to the semantics commonly inferred by other programmers. The existing use of + for string concatenation in Rust is often criticized, in this forum and elsewhere, because it does NOT adhere to the semantics of numeric addition.


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.