-
Notifications
You must be signed in to change notification settings - Fork 18
[Guideline] Add do not divide by 0 #132
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
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for scrc-coding-guidelines ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Hi @vapdrs! I have already sent you a message in Zulip, but here seems like a better place to do so. I come to add a couple of things to this guideline :)
There are other such operations for division, such as And for other arithmetic operations, there are quite a few functions one can use to avoid Undefined Behavior: https://doc.rust-lang.org/std/?search=checked
This combines rather well with Option, as in Option<NonZero>, since the compiler can do some memory layout optimization due to the fact that the value being enclosed by NonZero has one bit-pattern that is known to not be possible (the 000...000 pattern) I will review the PR shortly :3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for opening this up @vapdrs! Could you check the comments I left?
As stated there is no compliant way to do this, so no example should be present.
While the guideline does not strictly apply to this example, it is a good suggestion for what to do instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pulling this together @vapdrs! I left a few suggestions based on how conf.py
works together with Sphinx Needs as well as a way to use our coding guidelines extension. Could you take a look?
Co-authored-by: Pete LeVasseur <[email protected]>
Co-authored-by: Pete LeVasseur <[email protected]>
It is not recommended for normative language Co-authored-by: Alex Eris Celeste née Gilding <[email protected]>
Also moved to the Rationale.
Mandatory is a bit strong for panics as determined in today's meeting.
I haven't been able to give the examples a proper re-read just yet. Tis' been a low-battery week. Will do my best to have final feedback on those (also regarding #136) |
@vapdrs the build is failing, but to no fault of your own. It's just something that happens every now and then when the FLS and our FLS lockfile diverge. There should be a way to automate this for most PRs, but for right now... let's see. I'd usually ask you to run the command that fixes this, but for traceability purposes we actually want those changes to be their own Pull Requests. Lemme fix this in |
@vapdrs thanks! I was gonna ping you here as well but you just did the thing ❤️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these are the last few touches I'd add.
Co-authored-by: Félix Fischer <[email protected]>
Co-authored-by: Félix Fischer <[email protected]>
Closes #131