Cursor rule
.cursor/rules/code-style.mdcRust code style and conventions for skia-rs
Cursor rules
Quality
62/100
Scores the file, not the repository.Length
330 words
8 headings · 5 code blocksRepository
28
— · pushed 21 days agoLast changed
3 days ago
First indexed 3 days ago.1234567# Code Style & Conventions89## Rust Edition & Version1011- **Edition**: 202412- **MSRV**: 1.8513- All code must compile on stable Rust1415## Naming Conventions1617- Follow Skia's naming where possible for API compatibility18- Use `snake_case` for functions and variables19- Use `PascalCase` for types and traits20- Prefix internal/private items with underscore only when necessary21- Crate names: `skia-rs-{module}` (hyphenated)22- Module imports: `skia_rs_{module}` (underscored)2324## Type Aliases2526```rust27// Core type alias - matches Skia's SkScalar28pub type Scalar = f32;29```3031## Documentation3233- All public items MUST have doc comments34- Use `//!` for module-level documentation35- Include examples in doc comments for complex APIs36- Reference corresponding Skia types/functions in docs3738```rust39/// A 2D point with floating-point coordinates.40///41/// Corresponds to Skia's `SkPoint`.42///43/// # Examples44/// ```45/// use skia_rs_core::Point;46/// let p = Point::new(10.0, 20.0);47/// assert_eq!(p.length(), (500.0_f32).sqrt());48/// ```49#[derive(Debug, Clone, Copy, PartialEq, Default)]50#[repr(C)]51pub struct Point {52 pub x: Scalar,53 pub y: Scalar,54}55```5657## Error Handling5859- Use `thiserror` for error types60- Prefer `Option<T>` over `Result<T, E>` for simple failure cases (matching Skia patterns)61- Never panic in library code except for invariant violations62- Use `debug_assert!` for development-time checks6364## Memory & Performance6566- Use `#[repr(C)]` for FFI-compatible structs67- Derive `bytemuck::{Pod, Zeroable}` for types that need zero-copy operations68- Use `SmallVec` for small, stack-allocated collections69- Prefer `&self` over `&mut self` where possible70- Avoid allocations in hot paths7172```rust73use bytemuck::{Pod, Zeroable};7475#[derive(Debug, Clone, Copy, Pod, Zeroable)]76#[repr(C)]77pub struct Color(pub u32);78```7980## Inline Hints8182- Use `#[inline]` for small, frequently-called methods83- Use `#[inline(always)]` sparingly, only for critical hot paths84- Let the compiler decide for complex functions8586```rust87impl Point {88 #[inline]89 pub const fn new(x: Scalar, y: Scalar) -> Self {90 Self { x, y }91 }9293 #[inline]94 pub fn length(&self) -> Scalar {95 (self.x * self.x + self.y * self.y).sqrt()96 }97}98```99
Also in quinnjr/skia-rs
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| quinnjr/skia-rs.cursor/rules/api-design.mdc · 28 | Cursor rules | buildstyleapi | 58/100 | 3 days ago | |
| quinnjr/skia-rs.cursor/rules/ffi.mdc · 28 | Cursor rules | typesapi | 45/100 | 3 days ago | |
| quinnjr/skia-rs.cursor/rules/architecture.mdc · 28 | Cursor rules | archdependenciesmonorepo | 62/100 | 3 days ago | |
| quinnjr/skia-rs.cursor/rules/benchmarking.mdc · 28 | Cursor rules | styleperformance | 69/100 | 3 days ago | |
| quinnjr/skia-rs.cursor/rules/commands.mdc · 28 | Cursor rules | buildtestlint-formatgit+4 | 82/100 | 3 days ago | |
| quinnjr/skia-rs.cursor/rules/fuzzing.mdc · 28 | Cursor rules | setupstyle | 69/100 | 3 days ago | |
| quinnjr/skia-rs.cursor/rules/gpu.mdc · 28 | Cursor rules | no sections | 36/100 | 3 days ago | |
| quinnjr/skia-rs.cursor/rules/testing.mdc · 28 | Cursor rules | test | 69/100 | 3 days ago |
Diff against .cursor/rules/api-design.mdc Diff against .cursor/rules/ffi.mdc Diff against .cursor/rules/architecture.mdc Diff against .cursor/rules/benchmarking.mdc Diff against .cursor/rules/commands.mdc Diff against .cursor/rules/fuzzing.mdc Diff against .cursor/rules/gpu.mdc Diff against .cursor/rules/testing.mdc
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45 | Cursor rules | testlint-formatstylearch+5 | 100/100 | 3 days ago | |
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| markstev/mark-starter.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+6 | 99/100 | 3 days ago | |
| deifos/clipmira-subtitles.cursor/rules/frontend.mdc · 1 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| langflow-ai/langflow.cursor/rules/docs_development.mdc · 153k | Cursor rules | setupbuildtestlint-format+7 | 97/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45 | Cursor rules | teststyletesting-strategysecurity+3 | 97/100 | 3 days ago |
