|
17 | 17 | - All modules, classes, and functions should include docstrings. |
18 | 18 | - Tests must use descriptive function names, pytest style assertions, and be |
19 | 19 | grouped in classes when appropriate. |
20 | | -- Rust code must pass `cargo fmt`, `cargo clippy`, and `cargo tomlfmt` and |
21 | | - should omit unnecessary parentheses around `if` conditions. |
| 20 | +- Rust code must pass `cargo fmt`, `cargo clippy`, and `cargo tomlfmt`. |
22 | 21 | - Install the pre-commit hooks with `pre-commit install` and run them with |
23 | 22 | `pre-commit run --files <file1> <file2>` or `pre-commit run --all-files`. |
| 23 | + |
| 24 | +Install the required Rust components before running pre-commit: |
| 25 | + |
| 26 | +```bash |
| 27 | +rustup component add rustfmt clippy |
| 28 | +``` |
| 29 | + |
| 30 | +If installation is blocked by a proxy, see the [offline installation guide](https://rust-lang.github.io/rustup/installation/other.html). |
| 31 | + |
24 | 32 | - The same checks can be run manually using the scripts in `ci/scripts`: |
25 | 33 | - `./ci/scripts/python_lint.sh` |
26 | 34 | - `./ci/scripts/rust_fmt.sh` |
27 | 35 | - `./ci/scripts/rust_clippy.sh` |
28 | 36 | - `./ci/scripts/rust_toml_fmt.sh` |
29 | 37 |
|
| 38 | +## Rust Code Style |
| 39 | + |
| 40 | +When generating Rust code for DataFusion, follow these guidelines: |
| 41 | + |
| 42 | +1. Do not add unnecessary parentheses around `if` conditions: |
| 43 | + - Correct: `if some_condition` |
| 44 | + - Incorrect: `if (some_condition)` |
| 45 | + |
| 46 | +2. Do not use `expect()` or `panic!()` except in tests - use proper error handling with `Result` types |
| 47 | + |
| 48 | +3. Follow the standard Rust style conventions from rustfmt |
| 49 | + |
30 | 50 | ## Code Organization |
31 | 51 | - Keep functions focused and under about 50 lines. |
32 | 52 | - Break complex tasks into well-named helper functions and reuse existing |
|
0 commit comments