awesome-cursorrules
awesome-cursorrules copied to clipboard
Request: Cursor rules for Rust 🦀
Rust is widely adopted and still there is not cursor rules for it. We should try add it!
# .cursorrules – Rust-focused
[language.rust]
formatter = "rustfmt"
formatterArgs = ["--edition", "2021", "--unstable-features"]
linter = "clippy"
linterArgs = ["--all-targets", "--all-features", "--deny=warnings"]
checkCommand = "cargo check"
testCommand = "cargo test"
formatOnSave = true
lintOnSave = true
autoFix = true
[rules]
# Encourage idiomatic error handling
errorHandling = """
Always use `Result` with `?` operator over `unwrap` or `expect` in non-test code.
Prefer `anyhow` or `thiserror` for error propagation in binaries/libraries.
"""
# Enforce module documentation
docComments = """
Every public function, struct, enum, and trait must have a `///` doc comment.
Use examples with ```rust and run-tested code.
"""
# Enforce Clippy pedantic lints
clippyPedantic = "Enable Clippy pedantic lints and maintain warnings-clean build"
# Maintain consistent imports
imports = """
Group imports by std, external crates, then internal modules.
Use `crate::` and absolute paths for internal imports.
"""
# Encourage benchmarking
benchmarks = """
For performance-critical crates: include benches/ using `criterion`.
Run `cargo bench` as part of review process.
"""
# Enforce formatting of cargo.toml
cargoToml = """
In Cargo.toml:
- Keep version in sync with changelog.
- Include authors, license, repository fields.
- Depend on specific versions or use semver compatible `"^1.2"`.
"""
[files]
exclude = ["target", "node_modules", ".git", ".vscode", ".idea"]
[assistants.default]
context = ["file", "workspace", "cargo.toml"]
autoComplete = true
autoFixSuggestions = true
[snippets]
simple_fn = """
pub fn ${1:name}(${2:args}) -> ${3:ReturnType} {
${0:/* TODO implement */ }
}
"""
test_fn = """
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn ${1:test_name}() {
${0:assert_eq!(some_fn(), expected);}
}
}
"""
[commands]
fmt = "cargo fmt"
lint = "cargo clippy --all-targets --all-features -- -D warnings"
check = "cargo check"
build = "cargo build --release"
test = "cargo test"
bench = "cargo bench"
run = "cargo run"
This is a rough file GPT came up with, I will clean this up for my own personal usage later, lmk if this is helpful