Debian Codegraph @

debian/rust-vendor/crc-fast/.kiro/steering/commenting-guidelines.md

raw
1 ---
2 inclusion: always
3 ---
4
5 # Code Commenting Guidelines
6
7 ## Comment Philosophy
8
9 - Only add comments when they explain WHY something is done a particular way
10 - NEVER explain WHAT the code is doing unless it's hard to understand without a comment
11 - Code should be self-documenting through clear naming and structure
12 - Comments should provide context, reasoning, or non-obvious implications
13
14 ## Examples
15
16 ### Good Comments (WHY)
17 ```rust
18 // Use 512KiB chunks because benchmarks showed this was fastest on Apple M2 Ultra
19 let chunk_size = chunk_size.unwrap_or(524288);
20
21 // Remove xorout since it's already been applied and needs to be re-added on final output
22 self.state = combine::checksums(
23 self.state ^ self.params.xorout,
24 other_crc,
25 other.amount,
26 self.params,
27 ) ^ self.params.xorout;
28 ```
29
30 ### Avoid (WHAT)
31 ```rust
32 // Set chunk_size to 524288 if None
33 let chunk_size = chunk_size.unwrap_or(524288);
34
35 // XOR the state with xorout
36 self.state = self.state ^ self.params.xorout;
37 ```
38
39 ### Exception: Complex Logic
40 Comments explaining WHAT are acceptable when the code logic is genuinely hard to follow:
41 ```rust
42 // Fold 8 bytes at a time using SIMD, then handle remainder with scalar operations
43 ```