rust-practices
/rust-practices
Stosuje konwencje kodu Rust w tym repozytorium: obsługę błędów, reguły no_std dla particlecode-core, geometrię, testy proptest i lintery.
- Autor
- skyengpro ↗
- Repozytorium
- qr-code ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 07.11.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 1
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 07.11.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
Co robi i kiedy
Stosuje konwencje kodu Rust w tym repozytorium: obsługę błędów, reguły no_std dla particlecode-core, geometrię, testy proptest i lintery.
Oryginalny opis (EN)
Rust coding conventions for this workspace — error handling, no_std rules for particlecode-core, numeric/geometry code, testing with proptest, docs and lints. Use whenever writing or reviewing Rust code in this repo.
Jak działa
- Crate boundaries
- Errors
- Numeric and geometry code
- API design
- Testing
- Style
Podgląd SKILL.md
---
name: rust-practices
description: Rust coding conventions for this workspace — error handling, no_std rules for particlecode-core, numeric/geometry code, testing with proptest, docs and lints. Use whenever writing or reviewing Rust code in this repo.
---
# Rust practices for Particle Code
## Crate boundaries
| Crate | May depend on | Rules |
| --- | --- | --- |
| `particlecode-core` | `alloc`, `libm`, `raptorq`, RustCrypto, `thiserror` | `no_std` + `alloc`. No `std::`, no floats via `f64::sin` (use `libm`), no I/O, no pixels. `std` feature only adds OS randomness. |
| `particlecode-vision` | core | The only crate that reads pixels. No rendering. |
| `particlecode-render` | core, tiny-skia, png, gif | The only crate that writes pixels. |
| `particlecode-shapes` / `-cli` | everything | Binaries; `anyhow` allowed here and only here. |
| `particlecode-ffi` | core, vision | Only crate allowed `unsafe` (`feed_camera_frame` reads camera planes by address; generated frb code). Every `unsafe` block gets a `// SAFETY:` comment. |
Never introduce a dependency cycle; tests that need rendering use `particlecode-render` as a
**dev-dependency**.
## Errors
* Libraries return typed errors (`thiserror` enums: `DecodeError`, `EncodeError`, ...).
No `anyhow` in libraries, no `Box<dyn Error>`.
* No `unwrap()`/`expect()` on data that comes from outside (camera frames, headers,
files). `expect("why this cannot fail")` is fine for true invariants.
* Decoding never panics on any input: every per-frame step either produces output or
rejects the frame. Fuzz targets enforce this for the header parser.
## Numeric and geometry code
* All geometry comes from `particlecode_core::layout` (pitch units, y down). Do not
hard-code positions or radii anywhere else.
* Casts between float and int are allowed (the pedantic cast lints are off) but clamp
before casting pixel coordinates.
* Determinism matters: encoder output must be bit-identical across platforms. Avoid
`HashMap` iteration order and platform-dependent float functions in anything that feeds
the encoder; use `libm`.
## API design
* Plain data (`FrameSpec`, `Header`, `Sym3`) derives `Debug, Clone, PartialEq` and
`serde` behind the `serde` feature.
* Prefer constructors returning `Result` over panicking validation.
* Public items are documented (`missing_docs` warns). Doc comments state units.
* Keep functions small enough to unit test; put pure math in free functions.
## Testing
* Unit tests live next to the code (`#[cfg(test)] mod tests`).
* Codec layers get **property tests** (`proptest`): encode → corrupt within the correction
bound → decode must round-trip; beyond the bound it must fail cleanly, never panic.
* Vision is tested on synthetic renders (`particlecode-render::synth`): blur, perspective,
noise, glare. Keep test images small (≤ 600 px) so `cargo test` stays fast.
* Long-running tests are `#[ignore]` with a comment saying how to run them.
## Style
* `cargo fmt` is law; `rustfmt.toml` sets width 100.
* Clippy runs with `-D warnings` including `pedantic` (see `[workspace.lints]`). Allow a
lint locally with `#[allow(clippy::xyz)] // reason` rather than globally.
* Match the surrounding code's comment density; comments explain *why*, not *what*.
Wersje
W bazie nie ma innych skilli o nazwie rust-practices.
Migawka bazy z 13.11.2026 · wersja paczki 855619f2d362 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100rust
Podpowiada dobre praktyki Rust przy pisaniu i przeglądzie kodu: struktura, wzorce, wydajność i obsługa błędów. - 100rust
Wskazuje, jak pisać i przeglądać kod Rust zgodnie z wytycznymi stylu, gdy użytkownik o to prosi. - 100rust-testing-quality
Pomaga pisać, organizować i uruchamiać testy w Rust: jednostkowe, integracyjne, doc testy, proptest, benchmarki criterion i cargo-mutants. - 100rust
Podpowiada konwencje kodowania i dobre praktyki Rust przy każdej pracy z plikami .rs. - 100rust-dev
Stosuje rygorystyczne standardy Rust, w tym obsługę błędów typu fail fast, architekturę workspace i zarządzanie zależnościami. - 90rust-testing
Pisze testy w aplikacjach Rust poza cargo test: jednostkowe, integracyjne, tokio, katalogi tymczasowe i proptest.