Przejdź do treści
Biblioteka skilli
Programowanie · Budowanie i kod

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.

Repozytorium
qr-code ↗
Licencja
MIT
Ostatnia zmiana repozytorium
07.11.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 07.11.2026, bez odwołań do wycofanych modeli i API.

Licencja

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

  1. Crate boundaries
  2. Errors
  3. Numeric and geometry code
  4. API design
  5. Testing
  6. Style
Sekcje z nagłówków SKILL.md, w oryginale · 59 linii, 450 słów
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.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.