Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document behavior of bitwise operators with boolean arguments #26349

Merged
merged 1 commit into from
Jun 18, 2015

Conversation

petrochenkov
Copy link
Contributor

I'm surprised that bitwise operators &, | and ^ are implemented for bool arguments, because inspection of boolean's bits is not something that should be encouraged and because && -> & is a common typo, but if they are implemented, then their behavior should be documented.

@rust-highfive
Copy link
Collaborator

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

@petrochenkov
Copy link
Contributor Author

r? @steveklabnik

Calls the `bitxor` method of the `std::ops::BitXor` trait.
* `<<`
: Left shift.
Calls the `shl` method of the `std::ops::Shl` trait.
* `>>`
: Right shift.
: Right shift (arithmetic).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we used to have arithmetic here, but iirc, @pnkfelix suggested that we remove it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was incorrectly documented as logical (here's the fix: f2e0810) but it is in fact arithmetic (#23421 (comment))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ha! Thanks :)

@steveklabnik
Copy link
Member

r=me after the 'arithmetic' question is solved

@steveklabnik
Copy link
Member

@bors: r+ rollup

@bors
Copy link
Contributor

bors commented Jun 16, 2015

📌 Commit a8f666f has been approved by steveklabnik

Manishearth added a commit to Manishearth/rust that referenced this pull request Jun 18, 2015
I'm surprised that bitwise operators `&`, `|` and `^` are implemented for `bool` arguments, because inspection of boolean's bits is not something that should be encouraged and because `&&` -> `&` is a common typo, but if they are implemented, then their behavior should be documented.
bors added a commit that referenced this pull request Jun 18, 2015
@bors bors merged commit a8f666f into rust-lang:master Jun 18, 2015
@petrochenkov petrochenkov deleted the bitwise branch September 21, 2015 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants