@@ -1674,40 +1674,49 @@ Binary operators expressions are given in terms of
1674
1674
1675
1675
#### Arithmetic operators
1676
1676
1677
- Binary arithmetic expressions require both their operands to be of the
1678
- same type, and can be applied only to numeric types, with the
1679
- exception of ` + ` , which acts both as addition operator on numbers and
1680
- as concatenate operator on vectors and strings .
1677
+ Binary arithmetic expressions are syntactic sugar for calls to built-in traits,
1678
+ defined in the ` core::ops ` module of the ` core ` library.
1679
+ This means that arithmetic operators can be overridden for user-defined types.
1680
+ The default meaning of the operators on standard types is given here .
1681
1681
1682
1682
` + `
1683
1683
: Addition and vector/string concatenation.
1684
+ Calls the ` add ` method on the ` core::ops::Add ` trait.
1684
1685
` - `
1685
1686
: Subtraction.
1687
+ Calls the ` sub ` method on the ` core::ops::Sub ` trait.
1686
1688
` * `
1687
1689
: Multiplication.
1690
+ Calls the ` mul ` method on the ` core::ops::Mul ` trait.
1688
1691
` / `
1689
1692
: Division.
1693
+ Calls the ` div ` method on the ` core::ops::Div ` trait.
1690
1694
` % `
1691
- : Remainder.
1695
+ : Modulo (a.k.a. "remainder").
1696
+ Calls the ` modulo ` method on the ` core::ops::Modulo ` trait.
1692
1697
1693
1698
#### Bitwise operators
1694
1699
1695
- Bitwise operators apply only to integer types, and perform their
1696
- operation on the bits of the two's complement representation of the
1697
- values.
1700
+ Bitwise operators apply are, like the [ arithmetic operators] ( #arithmetic-operators ) ,
1701
+ syntactic sugar for calls to built-in traits.
1702
+ This means that bitwise operators can be overridden for user-defined types.
1703
+ The default meaning of the operators on standard types is given here.
1698
1704
1699
1705
` & `
1700
1706
: And.
1707
+ Calls the ` bitand ` method on the ` core::ops::BitAnd ` trait.
1701
1708
` | `
1702
1709
: Inclusive or.
1710
+ Calls the ` bitor ` method on the ` core::ops::BitOr ` trait.
1703
1711
` ^ `
1704
1712
: Exclusive or.
1713
+ Calls the ` bitxor ` method on the ` core::ops::BitXor ` trait.
1705
1714
` << `
1706
1715
: Logical left shift.
1716
+ Calls the ` shl ` method on the ` core::ops::Shl ` trait.
1707
1717
` >> `
1708
1718
: Logical right shift.
1709
- ` >>> `
1710
- : Arithmetic right shift.
1719
+ Calls the ` shr ` method on the ` core::ops::Shr ` trait.
1711
1720
1712
1721
#### Lazy boolean operators
1713
1722
0 commit comments