Skip to content

Commit a8f666f

Browse files
committed
Document behavior of bitwise operators with boolean arguments
1 parent 1035645 commit a8f666f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/doc/reference.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -2768,22 +2768,24 @@ meaning of the operators on standard types is given here.
27682768
Like the [arithmetic operators](#arithmetic-operators), bitwise operators are
27692769
syntactic sugar for calls to methods of built-in traits. This means that
27702770
bitwise operators can be overridden for user-defined types. The default
2771-
meaning of the operators on standard types is given here.
2771+
meaning of the operators on standard types is given here. Bitwise `&`, `|` and
2772+
`^` applied to boolean arguments are equivalent to logical `&&`, `||` and `!=`
2773+
evaluated in non-lazy fashion.
27722774

27732775
* `&`
2774-
: And.
2776+
: Bitwise AND.
27752777
Calls the `bitand` method of the `std::ops::BitAnd` trait.
27762778
* `|`
2777-
: Inclusive or.
2779+
: Bitwise inclusive OR.
27782780
Calls the `bitor` method of the `std::ops::BitOr` trait.
27792781
* `^`
2780-
: Exclusive or.
2782+
: Bitwise exclusive OR.
27812783
Calls the `bitxor` method of the `std::ops::BitXor` trait.
27822784
* `<<`
27832785
: Left shift.
27842786
Calls the `shl` method of the `std::ops::Shl` trait.
27852787
* `>>`
2786-
: Right shift.
2788+
: Right shift (arithmetic).
27872789
Calls the `shr` method of the `std::ops::Shr` trait.
27882790

27892791
#### Lazy boolean operators

0 commit comments

Comments
 (0)