rust-advanced

rust-advanced is a cursor rule for Cursor from wangqiqi/cursor-ai-rules. It costs 0 tokens per session (2,409 once invoked), scanned A, original, MIT.

A set of advanced Rust development rules covering testing, performance, security, platform-specific code, and shared dependencies in Cargo workspaces.

In plain words
What is it for?
Use it when building Rust libraries, services, command-line tools, or multi-package workspaces. It guides unit and integration tests, performance improvements, security practices, and conditional code for Linux, macOS, and Windows.
Why use it?
It helps keep larger Rust projects consistent and reduces common problems with reliability, speed, security, and different operating systems.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when building Rust libraries, services, command-line tools, or multi-package workspaces. It guides unit and integration tests, performance improvements, security practices, and conditional code for Linux, macOS, and Windows.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/wangqiqi/cursor-ai-rules/rust-advanced
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/wangqiqi/cursor-ai-rules

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for rust-advanced

README.md
[![agentmods](https://agentmods.dev/badge/rules/wangqiqi/cursor-ai-rules/rust-advanced/github.svg)](https://agentmods.dev/rules/wangqiqi/cursor-ai-rules/rust-advanced)
Your own site
<a href="https://agentmods.dev/rules/wangqiqi/cursor-ai-rules/rust-advanced"><img src="https://agentmods.dev/badge/rules/wangqiqi/cursor-ai-rules/rust-advanced/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for rust-advanced

Your own site · 80×15
<a href="https://agentmods.dev/rules/wangqiqi/cursor-ai-rules/rust-advanced"><img src="https://agentmods.dev/badge/rules/wangqiqi/cursor-ai-rules/rust-advanced.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 2,409 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.02409
Opus 5.5 $0.00000 $0.00964
Sonnet 5.5 $0.00000 $0.00482
Haiku 4.5 $0.00000 $0.00241

Measured 3mo ago against content hash 8f6a3a02b4f8, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

rust-advanced scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/tech/rust-advanced.mdc · 400 lines

How it starts

The opening of the file, as written. The whole thing — 400 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Rust 高级实践

本文档是从 @rust-basics 分割出来的高级主题部分,涵盖测试策略、性能优化、安全实践和最佳实践。

Cargo.toml (工作区根)

[workspace] members = [ "crates/core", "crates/api", "crates/cli", "crates/utils", ]

[workspace.dependencies]

共享依赖版本

serde = "1.0" tokio = "1.0" anyhow = "1.0"


### 条件编译
```rust
// 使用条件编译处理平台差异
#[cfg(target_os = "linux")]
mod linux_specific {
    pub fn get_os_info() -> String {
        "Linux".to_string()
    }
}

#[cfg(target_os = "macos")]
mod macos_specific {
    pub fn get_os_info() -> String {
        "macOS".to_string()
    }
}

#[cfg(target_os = "windows")]
mod windows_specific {
    pub fn get_os_info() -> String {
        "Windows".to_string()
    }
}

pub fn get_platform_info() -> String {
    #[cfg(target_os = "linux")]
    return linux_specific::get_os_info();

    #[cfg(target_os = "macos")]
    return macos_specific::get_os_info();

    #[cfg(target_os = "windows")]
    return windows_specific::get_os_info();

    #[allow(unreachable_code)]
    "Unknown".to_string()
}

🧪 测试策略

单元测试和集成测试

#[cfg(test)]
mod tests {
    use super::*;
    use std::sync::Arc;

    // ✅ 推荐:单元测试
    #[test]
    fn test_user_creation() {
        let username = "john_doe".to_string();
        let email = "[email protected]".to_string();

        let user = User::new(username.clone(), email.clone());

        assert_eq!(user.username, username);
        assert_eq!(user.email, email);
        assert_eq!(user.id, 0); // 默认ID
        assert!(user.created_at <= chrono::Utc::now());
    }

    #[test]
    fn test_user_validation() {
        // 有效用户
        let user = User::new("john".to_string(), "[email protected]".to_string());
        assert!(user.validate().is_ok());

        // 无效用户名
        let invalid_user = User::new("".to_string(), "[email protected]".to_string());
        assert!(invalid_user.validate().is_err());

        // 无效邮箱
        let invalid_user2 = User::new("john".to_string(), "invalid-email".to_string());
        assert!(invalid_user2.validate().is_err());
    }

Read the full file on GitHub · 400 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3mo ago First seen · 400 lines · 0 tokens per session scan A 8f6a3a02b4f8

Subscribe to this mod's changes

rust-advanced is a cursor rule published in the GitHub repository wangqiqi/cursor-ai-rules (16 stars, last pushed 6mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,409 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

rust-advanced compared with cursor rules from other repositories

rust-advanced next to 6 cursor rules from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
rust-advancedwangqiqi/cursor-ai-rulesCursor rule166mo agoMITA0Cursor
rust-architectplatinoff/poolAICursor rule4yesterdayMITA3,367Cursor
rust-development-standardsbeettlle/pi-spineCursor rule3todayMITA0Cursor
coreSaynaAI/saynaCursor rule3186mo agoApache-2.0A1,582Cursor
table-of-contents-standardbriangmilnes/APAS-VERUSCursor rule102mo agoMITA795Cursor
arc-deref-patternbriangmilnes/APAS-VERUSCursor rule102mo agoMITA793Cursor
wrap-vs-specifybriangmilnes/APAS-VERUSCursor rule102mo agoMITA0Cursor