File tree 1 file changed +8
-3
lines changed
1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 10
10
11
11
//! Overloadable operators.
12
12
//!
13
- //! Implementing these traits allows you to get an effect similar to
14
- //! overloading operators.
13
+ //! Implementing these traits allows you to overload certain operators.
15
14
//!
16
15
//! Some of these traits are imported by the prelude, so they are available in
17
- //! every Rust program.
16
+ //! every Rust program. Only operators backed by traits can be overloaded. For
17
+ //! example, the addition operator (`+`) can be overloaded through the `Add`
18
+ //! trait, but since the assignment operator (`=`) has no backing trait, there
19
+ //! is no way of overloading its semantics. Additionally, this module does not
20
+ //! provide any mechanism to create new operators. If traitless overloading or
21
+ //! custom operators are required, you should look toward macros or compiler
22
+ //! plugins to extend Rust's syntax.
18
23
//!
19
24
//! Many of the operators take their operands by value. In non-generic
20
25
//! contexts involving built-in types, this is usually not a problem.
You can’t perform that action at this time.
0 commit comments