docs: add a style guide

#5685
This commit is contained in:
Martin von Zweigbergk 2025-04-10 09:33:48 -07:00
parent 4bd6dbe83c
commit 42bf17936f
2 changed files with 16 additions and 1 deletions

View File

@ -115,7 +115,6 @@ directory](https://github.com/jj-vcs/jj/tree/main/cli/src/commands). Working
on them requires setting up a Rust development environment, as described
below, and may occasionally require adjusting a test.
## Learning Rust
In addition to the [Rust Book](https://doc.rust-lang.org/book/) and the other
@ -123,6 +122,10 @@ excellent resources at <https://www.rust-lang.org/learn>, we recommend the
["Comprehensive Rust" mini-course](https://google.github.io/comprehensive-rust/)
for an overview, especially if you are familiar with C++.
## Style guide
See [here](style_guide.md).
## Setting up a development environment
To develop `jj`, the mandatory steps are simply

12
docs/style_guide.md Normal file
View File

@ -0,0 +1,12 @@
# Style guide
## Panics
Panics are not allowed, especially in code that may run on a server. Calling
`.unwrap()` is okay if it's guaranteed to be safe by previous checks or
documented invariants. For example, if a function is documented as requiring
a non-empty slice as input, it's fine to call `slice[0]` and panic.
## Markdown
Try to wrap at 80 columns. We don't have a formatter yet.