Code Style
Formatting
The project uses rustfmt with settings in rustfmt.toml. Format before committing:
cargo fmt --all
Lints
Clippy is configured at maximum strictness in Cargo.toml:
clippy::pedantic— enabledclippy::expect_used— denied (no.expect()outside tests)clippy::unwrap_used— denied (no.unwrap()outside tests)clippy::indexing_slicing— denied (use.get()with explicit handling)
Run the full lint check:
cargo clippy --workspace --all-targets -- -D warnings
Lint Suppression
Use #[expect(lint)] instead of #[allow(lint)]. The expect attribute warns if the suppressed lint stops firing, preventing stale suppressions from accumulating.
#![allow(unused)]
fn main() {
#[expect(clippy::cast_possible_truncation)]
fn small_index(n: usize) -> u8 {
n as u8
}
}
Error Handling
- All error types use
thiserror. - No
anyhowindomain/oradapters/. - Propagate errors with
?. Match orif letwhen recovery is needed.
Commits
Use conventional commits:
feat: add dead-drop platform support
fix: handle empty cover image gracefully
refactor: extract shard validation into helper
test: add ZWJ emoji round-trip tests
docs: document time-lock calibration
Standard Library Preferences
Prefer modern standard library features over third-party crates:
| Prefer | Over |
|---|---|
std::sync::LazyLock | lazy_static!, once_cell |
Vec::extract_if | manual filter/retain loops |
<[T]>::array_windows | manual index arithmetic |
str::floor_char_boundary | unchecked byte slicing |
strict_add / strict_sub / strict_mul | checked_add().unwrap() |