-
Notifications
You must be signed in to change notification settings - Fork 19
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
Provide some code style for rust #499
base: main
Are you sure you want to change the base?
Conversation
Deploying contributing-docs with Cloudflare Pages
|
New Issues
|
|
||
## Discourage match | ||
|
||
Rust often provide good alternatives to doing match on `Option`s and `Result`s. |
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.
nit(non-blocking): looks weird and works without the "s"
Rust often provide good alternatives to doing match on `Option`s and `Result`s. | |
Rust often provide good alternatives to doing match on `Option` and `Result`. |
|
||
Some scenarios where `expect` are allowed are: | ||
|
||
- Calling libraries that guarantee that the allowed inputs never results in Err or None. |
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.
- Calling libraries that guarantee that the allowed inputs never results in Err or None. | |
- Calling libraries that guarantee that the allowed inputs never results in `Err` or `None`. |
|
||
## Avoid panics | ||
|
||
Panics are forbidden in the Bitwarden codebase outside of tests. Errors should be handled gracefully |
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.
Technically expect
results in a panic, therefore panics are not forbidden, only unwrap
is forbidden.
suggestion:
Panics are forbidden in the Bitwarden codebase outside of tests. Errors should be handled gracefully | |
Panics are highly discouraged in the Bitwarden codebase outside of tests. Errors should be handled gracefully |
### Options | ||
|
||
We use `clippy` to enforce general guidelines for working with | ||
[`Option`](https://doc.rust-lang.org/std/option/enum.Option.html)s. Generally reach for methods |
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.
nit(non-blocking): same here, works without the "s"
[`Option`](https://doc.rust-lang.org/std/option/enum.Option.html)s. Generally reach for methods | |
[`Option`](https://doc.rust-lang.org/std/option/enum.Option.html). Generally reach for methods |
|
||
### Results | ||
|
||
When working on [`Result`](https://doc.rust-lang.org/std/result/enum.Result.html)s it might be |
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.
nit(non-blocking):
When working on [`Result`](https://doc.rust-lang.org/std/result/enum.Result.html)s it might be | |
When working with [`Result`](https://doc.rust-lang.org/std/result/enum.Result.html) it might be |
📔 Objective
Write some code style guidelines for writing rust.
⏰ Reminders before review
team
🦮 Reviewer guidelines
:+1:
) or similar for great changes:memo:
) or ℹ️ (:information_source:
) for notes or general info:question:
) for questions:thinking:
) or 💭 (:thought_balloon:
) for more open inquiry that's not quite a confirmedissue and could potentially benefit from discussion
:art:
) for suggestions / improvements:x:
) or:warning:
) for more significant problems or concerns needing attention:seedling:
) or ♻️ (:recycle:
) for future improvements or indications of technical debt:pick:
) for minor or nitpick changes