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

Bit wise operations missing? #151

Open
doronbehar opened this issue Dec 3, 2021 · 7 comments
Open

Bit wise operations missing? #151

doronbehar opened this issue Dec 3, 2021 · 7 comments
Labels
help-wanted Help especially wanted. type: content Actual content to appear on cheat sheet.

Comments

@doronbehar
Copy link

I'm a bit new to rust and I encountered the symbol << which I wanted to know what does it mean and I didn't found it on the website. It'd be great if it was added in a proper location, with a link to here:

https://doc.rust-lang.org/stable/std/ops/trait.Shr.html

Thanks a lot for maintaining this website.

@ShadowJonathan
Copy link

I would also like to see this, in other languages I haven't used these operations much, and knowing how they (could) behave on rust would be nice.

@ralfbiedert ralfbiedert added the type: content Actual content to appear on cheat sheet. label Dec 3, 2021
@ralfbiedert
Copy link
Owner

ralfbiedert commented Dec 3, 2021

Thanks for the feedback. My reasoning so far has been documenting "common operators one would know coming from another language" does not really explain anything to our target audience (experienced programmers, new to Rust) and just takes up space.

That said, you have a point that there's value documenting their behavior w.r.t. Rust specifics. How about something like this:

Operator Description
a + b Invokes Add<B> on A. Integers overflow in release builds or turn panics in debug.

PRs welcome. I think a quick mock would be good to get a feeling for much much wall-of-text that becomes if done with all operators; but as long as it looks good (TM) I can see this getting merged.

@ShadowJonathan
Copy link

ShadowJonathan commented Dec 3, 2021

Ah, i think documenting "rust operands are just invoked traits" with a table like that would be really useful onto itself, actually 👀

@ralfbiedert ralfbiedert added the help-wanted Help especially wanted. label Dec 3, 2021
@mattrobineau
Copy link

@doronbehar I was just looking at bitwise operators last night.

@ralfbiedert What about using the Table B-1 from the rust book?

@ralfbiedert
Copy link
Owner

What about using the Table B-1 from the rust book?

I don't think that table fits as-is, I'd still start experimenting with some format mentioned above.

@glasser
Copy link

glasser commented Mar 18, 2023

On a related note, while I agree that it's reasonable to expect users to be familiar with the standard operators, it might be nice to at list them really compactly. For example, it's not too uncommon to use and and or rather than && and || for logical operators these days (eg Python), and it might not be to strange to wonder if Rust has an exponentiation operator or distinct division operators for rounding vs not. Even just a section that lists the main operators in groups like "logical", "bitwise", "arithmetic", etc without documenting each symbol individually could be nice?

That is, I think there's value in saying "these are the Rust operators, you can probably guess what they do" rather than just "Rust probably has the operators that you might imagine exist".

@ralfbiedert
Copy link
Owner

That is, I think there's value in saying "these are the Rust operators, you can probably guess what they do" rather than just "Rust probably has the operators that you might imagine exist".

Yes good point. Right now the main thing that's missing is a good idea how to write and layout that table so it "blends in". I once tried the obvious

x + y     Adds x and y.
...

But that got tedious real fast.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help-wanted Help especially wanted. type: content Actual content to appear on cheat sheet.
Projects
None yet
Development

No branches or pull requests

5 participants