RuleStack

Configs

Stacks

Compare

Diff

RuleStack

Configs

Stacks

Compare

Diff

Read API

RuleStack

Configs

Stacks

Compare

Diff

Read API

Configs/Cursor rules/ThanhTrunggDEV/DontBeLazy

Cursor rule

.cursor/rules/rust-coding-style.mdc
Cursor rules

Quality

78/100

Scores the file, not the repository.

Length

560 words

10 headings · 5 code blocks

Repository

6

— · pushed 80 days ago

Last changed

3 days ago

First indexed 3 days ago.
ThanhTrunggDEV/DontBeLazy/.cursor/rules/rust-coding-style.mdcRawGitHub
1---
2paths:
3 - "**/*.rs"
4---
5# Rust Coding Style
6 
7> This file extends [common/coding-style.md](../common/coding-style.md) with Rust-specific content.
8 
9## Formatting
10 
11- **rustfmt** for enforcement — always run `cargo fmt` before committing
12- **clippy** for lints — `cargo clippy -- -D warnings` (treat warnings as errors)
13- 4-space indent (rustfmt default)
14- Max line width: 100 characters (rustfmt default)
15 
16## Immutability
17 
18Rust variables are immutable by default — embrace this:
19 
20- Use `let` by default; only use `let mut` when mutation is required
21- Prefer returning new values over mutating in place
22- Use `Cow<'_, T>` when a function may or may not need to allocate
23 
24```rust
25use std::borrow::Cow;
26 
27// GOOD — immutable by default, new value returned
28fn normalize(input: &str) -> Cow<'_, str> {
29 if input.contains(' ') {
30 Cow::Owned(input.replace(' ', "_"))
31 } else {
32 Cow::Borrowed(input)
33 }
34}
35 
36// BAD — unnecessary mutation
37fn normalize_bad(input: &mut String) {
38 *input = input.replace(' ', "_");
39}
40```
41 
42## Naming
43 
44Follow standard Rust conventions:
45- `snake_case` for functions, methods, variables, modules, crates
46- `PascalCase` (UpperCamelCase) for types, traits, enums, type parameters
47- `SCREAMING_SNAKE_CASE` for constants and statics
48- Lifetimes: short lowercase (`'a`, `'de`) — descriptive names for complex cases (`'input`)
49 
50## Ownership and Borrowing
51 
52- Borrow (`&T`) by default; take ownership only when you need to store or consume
53- Never clone to satisfy the borrow checker without understanding the root cause
54- Accept `&str` over `String`, `&[T]` over `Vec<T>` in function parameters
55- Use `impl Into<String>` for constructors that need to own a `String`
56 
57```rust
58// GOOD — borrows when ownership isn't needed
59fn word_count(text: &str) -> usize {
60 text.split_whitespace().count()
61}
62 
63// GOOD — takes ownership in constructor via Into
64fn new(name: impl Into<String>) -> Self {
65 Self { name: name.into() }
66}
67 
68// BAD — takes String when &str suffices
69fn word_count_bad(text: String) -> usize {
70 text.split_whitespace().count()
71}
72```
73 
74## Error Handling
75 
76- Use `Result<T, E>` and `?` for propagation — never `unwrap()` in production code
77- **Libraries**: define typed errors with `thiserror`
78- **Applications**: use `anyhow` for flexible error context
79- Add context with `.with_context(|| format!("failed to ..."))?`
80- Reserve `unwrap()` / `expect()` for tests and truly unreachable states
81 
82```rust
83// GOOD — library error with thiserror
84#[derive(Debug, thiserror::Error)]
85pub enum ConfigError {
86 #[error("failed to read config: {0}")]
87 Io(#[from] std::io::Error),
88 #[error("invalid config format: {0}")]
89 Parse(String),
90}
91 
92// GOOD — application error with anyhow
93use anyhow::Context;
94 
95fn load_config(path: &str) -> anyhow::Result<Config> {
96 let content = std::fs::read_to_string(path)
97 .with_context(|| format!("failed to read {path}"))?;
98 toml::from_str(&content)
99 .with_context(|| format!("failed to parse {path}"))
100}
101```
102 
103## Iterators Over Loops
104 
105Prefer iterator chains for transformations; use loops for complex control flow:
106 
107```rust
108// GOOD — declarative and composable
109let active_emails: Vec<&str> = users.iter()
110 .filter(|u| u.is_active)
111 .map(|u| u.email.as_str())
112 .collect();
113 
114// GOOD — loop for complex logic with early returns
115for user in &users {
116 if let Some(verified) = verify_email(&user.email)? {
117 send_welcome(&verified)?;
118 }
119}
120```
121 
122## Module Organization
123 
124Organize by domain, not by type:
125 
126```text
127src/
128├── main.rs
129├── lib.rs
130├── auth/ # Domain module
131│ ├── mod.rs
132│ ├── token.rs
133│ └── middleware.rs
134├── orders/ # Domain module
135│ ├── mod.rs
136│ ├── model.rs
137│ └── service.rs
138└── db/ # Infrastructure
139 ├── mod.rs
140 └── pool.rs
141```
142 
143## Visibility
144 
145- Default to private; use `pub(crate)` for internal sharing
146- Only mark `pub` what is part of the crate's public API
147- Re-export public API from `lib.rs`
148 
149## References
150 
151See skill: `rust-patterns` for comprehensive Rust idioms and patterns.
152 

Commands it names

  • cargo fmt
  • cargo clippy -- -D warnings

Sections

  • Rust Coding Style
  • Formatting
  • Immutability
  • Naming
  • Ownership and Borrowing
  • Error Handling
  • Iterators Over Loops
  • Module Organization
  • Visibility
  • References

What it covers

lint-formatcode-style

Stack — with the evidence

javascript

(0.80)

csharp

(0.60)

dotnet

(0.60)

github-actions

(0.60)

Format

Cursor rules

The most expressive format here. Many small .mdc files, each with frontmatter declaring when it should load, so a rule about migrations only enters context when a migration is open. Costs the most to maintain and only one editor reads it.

What the corpus says about it

Repository

Owner
ThanhTrunggDEV
Language
—
License
—
Archived
no

All configs in this repo

Also in ThanhTrunggDEV/DontBeLazy

Diff this repo’s formats

One 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?

The other instruction files in this repository
RepositoryFormatStackCoversScoreChanged
ThanhTrunggDEV/DontBeLazy.cursor/rules/zh-agents.mdc · 6Cursor rulesjavascriptcsharp+2no sections50/1003 days ago
ThanhTrunggDEV/DontBeLazy.cursor/rules/zh-patterns.mdc · 6Cursor rulesjavascriptcsharp+2api30/1003 days ago
ThanhTrunggDEV/DontBeLazy.agent/AGENTS.md · 6AGENTS.mdjavascriptcsharp+2buildteststylearch+477/1003 days ago
ThanhTrunggDEV/DontBeLazy.cursor/AGENTS.md · 6AGENTS.mdjavascriptcsharp+2buildteststylearch+477/1003 days ago
ThanhTrunggDEV/DontBeLazy.cursor/rules/common-agents.mdc · 6Cursor rulesjavascriptcsharp+2agent-behaviour50/1003 days ago
ThanhTrunggDEV/DontBeLazy.cursor/rules/common-code-review.mdc · 6Cursor rulesjavascriptcsharp+2styletesting-strategygitsecurity+365/1003 days ago
ThanhTrunggDEV/DontBeLazy.cursor/rules/common-coding-style.mdc · 6Cursor rulesjavascriptcsharp+2style54/1003 days ago
ThanhTrunggDEV/DontBeLazy.cursor/rules/common-development-workflow.mdc · 6Cursor rulesjavascriptcsharp+2gitagent-behaviour39/1003 days ago
ThanhTrunggDEV/DontBeLazy.cursor/rules/common-git-workflow.mdc · 6Cursor rulesjavascriptcsharp+2lint-formatgitagent-behaviour43/1003 days ago
ThanhTrunggDEV/DontBeLazy.cursor/rules/common-hooks.mdc · 6Cursor rulesjavascriptcsharp+2styletypessecuritydo-not36/1003 days ago
ThanhTrunggDEV/DontBeLazy.cursor/rules/common-patterns.mdc · 6Cursor rulesjavascriptcsharp+2lint-formatstyleapi52/1003 days ago
ThanhTrunggDEV/DontBeLazy.cursor/rules/common-performance.mdc · 6Cursor rulesjavascriptcsharp+2buildperformance48/1003 days ago
ThanhTrunggDEV/DontBeLazy.cursor/rules/common-security.mdc · 6Cursor rulesjavascriptcsharp+2security39/1003 days ago
ThanhTrunggDEV/DontBeLazy.cursor/rules/common-testing.mdc · 6Cursor rulesjavascriptcsharp+2testtesting-strategyagent-behaviour34/1003 days ago
ThanhTrunggDEV/DontBeLazy.cursor/rules/cpp-coding-style.mdc · 6Cursor rulesjavascriptcsharp+2lint-formatstyle52/1003 days ago
ThanhTrunggDEV/DontBeLazy.cursor/rules/cpp-hooks.mdc · 6Cursor rulesjavascriptcsharp+2buildlint-formatdeployment60/1003 days ago
ThanhTrunggDEV/DontBeLazy.cursor/rules/cpp-patterns.mdc · 6Cursor rulesjavascriptcsharp+2style54/1003 days ago
ThanhTrunggDEV/DontBeLazy.cursor/rules/cpp-security.mdc · 6Cursor rulesjavascriptcsharp+2securityperformancedo-not73/1003 days ago
ThanhTrunggDEV/DontBeLazy.cursor/rules/cpp-testing.mdc · 6Cursor rulesjavascriptcsharp+2testtesting-strategy55/1003 days ago
ThanhTrunggDEV/DontBeLazy.cursor/rules/csharp-coding-style.mdc · 6Cursor rulesjavascriptcsharp+2lint-formatstyletypes66/1003 days ago
Diff against .cursor/rules/zh-agents.mdc Diff against .cursor/rules/zh-patterns.mdc Diff against .agent/AGENTS.md Diff against .cursor/AGENTS.md Diff against .cursor/rules/common-agents.mdc Diff against .cursor/rules/common-code-review.mdc Diff against .cursor/rules/common-coding-style.mdc Diff against .cursor/rules/common-development-workflow.mdc Diff against .cursor/rules/common-git-workflow.mdc Diff against .cursor/rules/common-hooks.mdc Diff against .cursor/rules/common-patterns.mdc Diff against .cursor/rules/common-performance.mdc Diff against .cursor/rules/common-security.mdc Diff against .cursor/rules/common-testing.mdc Diff against .cursor/rules/cpp-coding-style.mdc Diff against .cursor/rules/cpp-hooks.mdc Diff against .cursor/rules/cpp-patterns.mdc Diff against .cursor/rules/cpp-security.mdc Diff against .cursor/rules/cpp-testing.mdc Diff against .cursor/rules/csharp-coding-style.mdc

Similar configs

Same format, overlapping stack, ranked by quality.

Same format, overlapping stack, ranked by quality
RepositoryFormatStackCoversScoreChanged
hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126Cursor rulesgobun+5setupbuildtestlint-format+6100/1003 days ago
TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45Cursor rulestypescriptpytest+15testlint-formatstylearch+5100/1003 days ago
markstev/mark-starter.cursor/rules/frontend.mdc · 0Cursor rulestypescriptturborepo+14setuptestlint-formatstyle+699/1003 days ago
Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0Cursor rulestypescriptturborepo+13setuptestlint-formatstyle+799/1003 days ago
deifos/clipmira-subtitles.cursor/rules/frontend.mdc · 1Cursor rulestypescriptnextjs+5setuptestlint-formatstyle+799/1003 days ago
dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0Cursor rulestypescriptturborepo+15setuptestlint-formatstyle+799/1003 days ago
langflow-ai/langflow.cursor/rules/docs_development.mdc · 153kCursor rulespythonnode+16setupbuildtestlint-format+797/1003 days ago
TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45Cursor rulestypescriptpytest+15teststyletesting-strategysecurity+397/1003 days ago
RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack