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

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.

agentmods
npx agentmods add rules/wangqiqi/cursor-ai-rules/rust-advanced
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.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.svg" alt="Measured on agentmods" 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. Scan, not verified.
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 $0.00000 $0.02409
Opus 5 $0.00000 $0.01205
Sonnet 5 $0.00000 $0.00482
Haiku 4.5 $0.00000 $0.00241

Measured 3d ago against content hash 8f6a3a02b4f8, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 3d 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. 3d 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 (15 stars, last pushed 3mo 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.